Spain continues to claim sovereignty over the territory, which has been ruled by Britain since 1713 under the terms of the Treaty of Utrecht.
Named in Arabic "Jabal Tariq", after the Muslim commander Tariq Ibn-Ziyad, who turned "the Rock" into a fortress in 711, Gibraltar has been an important naval base for more than 1,000 years.
This long maritime history has resulted in a diverse population. Most Gibraltarians are bilingual in English and Spanish, and are of mixed Genoese, British, Spanish, Jewish, Maltese and Portuguese descent. Recent arrivals have included migrant workers from Morocco.
Gibraltarians are British citizens. They elect their own representatives to the territory's House of Assembly; the British monarch appoints a governor. Gibraltar is self-governing in all areas except defence and foreign policy. It is home to a British military garrison and naval base.
Profiles compiled by BBC Monitoring
The EU has pressured Spain and Britain to resolve the issue of Gibraltar's status. Both sides, under the Brussels Process launched in 1984, have attempted to reach an agreement.
But Spain's insistence on eventually acquiring full sovereignty, and Britain's determination to retain full control of Gibraltar's military base, have been among the stumbling blocks.
Gibraltar's 1969 constitution states that there can be no transfer of sovereignty to Spain against the wishes of locals. In a 2002 referendum Gibraltarians resoundingly rejected the idea of joint sovereignty. Spain and Britain were said to have reached "broad agreement" on the concept.
Free travel between Spain and Gibraltar was fully restored in 1985, but travellers continued to suffer delays at the border.
In late 2006, passenger flights between Spain and Gibraltar resumed for the first time in nearly 30 years, but 2013 saw renewed border checks by Spain in response to a Gibraltarian plan to build an artificial reef.
The air link was restored after Gibraltar, Spain and Britain signed agreements aimed at improving living conditions on the Rock. The three-way talks did not cover the issue of sovereignty.
With no large-scale agricultural or industrial activity, much of Gibraltar's income comes from customs duties, offshore finance, internet gaming, tourism and the provisioning of ships.
The British overseas territory of Gibraltar, a limestone outcrop on the southern tip of the Iberian peninsula, occupies a commanding position at the western gateway to the Mediterranean Sea.