In addition to its commanding position , Gibraltar provided a strongly defended harbour from which ships could operate in both the Atlantic and the Mediterranean . Force H , under the command of Vice @-@ Admiral James Somerville was based in Gibraltar and had the task of maintaining naval superiority and providing a strong escort for convoys to and from the besieged island of Malta . During the course of the war , Gibraltar came under aerial bombardment from Vichy French aircraft and from aircraft of the Italian Royal Air Force ( Regia Aeronautica ) based on Sardinia . Additionally , the fortress was the focus of underwater attacks by the Italian Royal Navy ( Regia Marina ) commando frogman unit ( Decima Flottiglia MAS ) and their human torpedoes . This Italian unit was based on the interned Italian ship SS Olterra in the nearby Spanish harbour of Algeciras . A number of attacks were also carried out by Spanish and Gibraltarian agents acting on behalf of the German Abwehr .