Gibraltar's strategic location at the entrance to the Mediterranean Sea made it essential for British naval operations during World War II. At one point it was about the only British-held area in the region, since the Germans had a foothold in southern Europe and North Africa. Most of the inhabitants of Gibraltar were relocated during the war, and the famous Rock of Gibraltar was heavily fortified. Tunnels were dug throughout the mountain, and heavy artillery was put in place for the defense of the territory. The British were able to control virtually all naval traffic between the Atlantic and Mediterranean during the war, and the invasion of North Africa (Operation Torch) was conducted from the defenses of Gibraltar. Gibraltar served as both a forward operations base during the campaigns in North Africa and a rear-area base of supplies following Italy's surrender in 1943. The British Royal Air Force built a landing strip and maintained a base on Gibraltar, which was attacked by Vichy French planes based in Morocco in 1940.
Hitler desperately wanted to capture Gibraltar, but he met with resistance from the neutral Spanish government. Hitler's plan to invade Gibraltar via Spain (with or without Spanish dictator Francisco Franco's approval) with troops pulled from the Russian front was eventually canceled. Gibraltar was attacked sporadically by Italian bombers and even a group of naval frogmen; Spanish saboteurs were also active intermittently. German U-boats tried to isolate Gibraltar from British supply ships, but they suffered heavy damage themselves while trying to negotiate the treacherous Strait of Gibraltar.