Promoted to rear admiral on 1 March 1703, Byng became third-in-command of the Mediterranean Fleet under Admiral Sir Cloudesley Shovell with his flag in the third-rate later that month. He led the bombardment squadron while serving under Admiral Sir George Rooke at the Capture of Gibraltar in August 1704 and then took part in the Battle of Málaga in August 1704. Knighted on 22 October 1704, and promoted to vice admiral on 3 January 1705, he was elected Member of Parliament for Plymouth later that year.