Gibraltar was known as Mons Calpe, a name of Phoenician origin and one of the Pillars of Hercules.
The Phoenicians inhabited Gibraltar around 950 BC. Subsequently, Gibraltar became known as one of the Pillars of Hercules, after the Greek legend of the creation of the Strait of Gibraltar by Heracles. The Carthaginians and Romans also established semi-permanent settlements. After the collapse of the Roman Empire, Gibraltar came briefly under the control of the Vandals, who crossed into Africa at the invitation of Boniface, the Count (or commander) of the territory. In prehistory evidence of Neanderthal habitation in Gibraltar has been discovered at Gorham's Cave.
The area later formed part of the Visigothic Kingdom of Hispania from 414 AD until the Islamic conquest of Iberia in 711 AD.
The name "Gibraltar" is the Spanish derivation of the Arabic name Jabal Ṭāriq (جبل طارق), meaning "mountain of Ṭāriq", which is named after Tariq ibn Ziyad (Arabic: طارق بن زياد) a Muslim commander who led the Islamic Umayyad conquest of Visigothic Hispania in 711–718 A.D.
In 1160, the Almohad Sultan Abd al-Mu'min ordered that a permanent settlement, including a castle, be built. It received the name of Medinat al-Fath (City of the Victory). On completion of the works in the town, the Sultan crossed the Strait to look at the works and stayed in Gibraltar for two months. The Tower of Homage of the Moorish Castle remains standing today. From 1274 onwards, the town was fought over and captured by the Nasrids of Granada (in 1237 and 1374), the Marinids of Morocco (in 1274 and 1333) and the kings of Castile (in 1309). In 1462, Gibraltar was finally captured by Juan Alonso de Guzmán, 1st Duke of Medina Sidonia.
After the conquest, Henry IV of Castile assumed the additional title of King of Gibraltar, establishing it as part of the comarca of the Campo Llano de Gibraltar. Six years later, Gibraltar was restored to the Duke of Medina Sidonia, who sold it in 1474 to a group of 4350 conversos (Christian converts from Judaism) from Cordova and Seville and in exchange for maintaining the garrison of the town for two years, after which time they were expelled, returning to their home towns or moving on to other parts of Spain. In 1501, Gibraltar passed back to the Spanish Crown, and Isabella I of Castile issued a Royal Warrant granting Gibraltar the coat of arms that it still uses today.
In 1704, during the War of the Spanish Succession, a combined Anglo-Dutch fleet, representing the Grand Alliance, captured the town of Gibraltar on behalf of the Archduke Charles of Austria in his campaign to become King of Spain. The occupation of the town by Alliance forces caused the exodus of the population to the surrounding area of the Campo de Gibraltar. As the Alliance's campaign faltered, the 1713 Treaty of Utrecht was negotiated and ceded control of Gibraltar to Britain to secure Britain's withdrawal from the war. Unsuccessful attempts by Spanish monarchs to regain Gibraltar were made with the siege of 1727 and again with the Great Siege of Gibraltar (1779 to 1783), during the American War of Independence.
Gibraltar became a key base for the Royal Navy and played an important role prior to the Battle of Trafalgar (21 October 1805) and during the Crimean War of 1854–56, because of its strategic location. Its strategic value increased with the opening of the Suez Canal, as it lay on the sea route between the UK and the British Empire east of Suez. In the later 19th century, there were major investments in improving the fortifications and the port.
Shown here during the Second World War, a Douglas Dakota
is silhouetted at Gibraltar by the batteries of searchlights on the Rock, as crews prepare it for a night flight to the United Kingdom.
During the Second World War, Gibraltar's civilian population was evacuated (mainly to London, but also to parts of Morocco and Madeira and to Gibraltar Camp in Jamaica, and the Rock was strengthened as a fortress. The naval base and the ships based there played a key role in the provisioning and supply of the island of Malta during its long siege. As well as frequent short runs (known as 'Club Runs') towards Malta to fly off aircraft reinforcements (initially Hurricanes but later, notably from the USN aircraft carrier Wasp, Spitfires), the critical Operation Pedestal convoy was run from Gibraltar in August 1942. This resupplied the island at a critical time in the face of concentrated air attacks from German and Italian forces. Spanish dictator Francisco Franco's reluctance to allow the German Army onto Spanish soil frustrated a German plan to capture the Rock, codenamed Operation Felix.
In the 1950s, Franco renewed Spain's claim to sovereignty over Gibraltar and restricted movement between Gibraltar and Spain. Gibraltarians voted overwhelmingly to remain under British sovereignty in the Gibraltar sovereignty referendum, 1967, which led to the passing of the Gibraltar Constitution Order in 1969. In response, Spain completely closed the border with Gibraltar and severed all communication links. The border with Spain was partially reopened in 1982 and fully reopened in 1985 before Spain's accession to the .
In a referendum held in 2002, Gibraltarians rejected by an overwhelming majority (98%) a proposal of shared sovereignty on which Spain and Britain were said to have reached "broad agreement". The British government has committed itself to respecting the Gibraltarians' wishes. A new Constitution Order was approved in referendum in 2006. A process of tripartite negotiations started in 2006 between Spain, Gibraltar and the UK, ending some restrictions and dealing with disputes in some specific areas such as air movements, customs procedures, telecommunications, pensions and cultural exchange.
In the British referendum on membership of the European Union 96% of Gibraltarians voted to remain on an 82% turnout. Spain renewed calls for joint Spanish–British control of the peninsula; these were strongly rebuffed by Gibraltar's Chief Minister.