Hamilton went on to take command of the third-rate in 1698, of the third-rate in 1699 and of the third-rate in 1702. After that he became captain of the third-rate in September 1702 and commanded her at the Battle of Vigo Bay in October 1702 during the War of the Spanish Succession. He took command of the third-rate in 1704 and commanded her at the Battle of Málaga in August 1704. He became captain of the second-rate in 1706.