The name Gibraltar derives from the Arabic Jabal-al-Tarik [mount of Tarik], dating from the capture (711) of the peninsula by the Moorish leader Tarik. The Spanish Held the peninsula (1309–33) but did not definitively recover it from the Moors until 1462. The English have maintained possession since 1704 despite continual Spanish claims. The British post was besieged unsuccessfully by the Spanish and French (1704), by the Spanish (1726), and again by the Spanish and French (1779–83).
In World War I, Gibraltar served as a naval station. Many refugees fled there in the Spanish civil war (1936–39). In World War II its fortifications were strengthened, and most of the civilian population was evacuated. It was frequently bombed in 1940–41, but not seriously damaged.
After the war Spain renewed claims to Gibraltar, which, as a British strategic air and naval base, continued to be a major source of friction between Britain and Spain. The residents affirmed (1967) their ties with Britain in a UN-supervised referendum, and in 1981 all residents were granted full British citizenship. From 1969 to 1985, Spain closed its border with Gibraltar, although pedestrian traffic was again permitted across beginning in 1982.
In 1991, Britain removed its military forces from Gibraltar, while retaining it as a dependency. Tensions between Spain and Gibraltar continued through the 1990s, however, as Spain accused Gibraltar of being a hotbed of drug trafficking, tobacco smuggling, money laundering, and tax evasion. A 1997 Spanish proposal for joint British-Spanish sovereignty was rejected by the Gibraltarian government, and a referendum in 2002 on shared British-Spanish sovereignty almost unanimously approved of that rejection. In 2006 Gibraltar, Spain, and Britain signed an agreement intended to ease crossing the Spanish border and traveling by air to Gibraltar and to improve telephone service in Gibraltar. The same year a new constitution for the colony was approved that increased its government's autonomy. A dispute over fishing grounds led to new tensions in 2013.