Strategically important Gibraltar was reluctantly ceded to Great Britain by Spain in the 1713 Treaty of Utrecht; the British garrison was formally declared a colony in 1830. In a referendum held in 1967 Gibraltarians voted overwhelmingly to remain a British dependency. The subsequent granting of autonomy in 1969 by the UK led to Spain closing the border and severing all communication links. A series of talks were held by the UK and Spain between 1997 and 2002 on establishing temporary joint sovereignty over Gibraltar. In response to these talks the Gibraltar Government called a referendum in late 2002 in which the majority of citizens voted overwhelmingly against any sharing of sovereignty with Spain. Since the referendum tripartite talks on other issues have been held with Spain the UK and Gibraltar and in September 2006 a three-way agreement was signed. Spain agreed to remove restrictions on air movements to speed up customs procedures to implement international telephone dialing and to allow mobile roaming agreements. Britain agreed to pay increased pensions to Spaniards who had been employed in Gibraltar before the border closed. Spain will be allowed to open a cultural institute from which the Spanish flag will fly. A new noncolonial constitution came into effect in 2007 but the UK retains responsibility for defense foreign relations internal security and financial stability.
Read more on Wikipedia