In 1713 the territory of Gibraltar was ceded to Great Britain in perpetuity under the Treaty of Utrecht. However, the first form of a physical border between Gibraltar and Spain was not established until 1730. The line of defence containing a fort, known as the Lines of Contravallation of Gibraltar (Línea de Contravalación de Gibraltar), was built by Spain at the north end of the isthmus in order to keep the British from attacking or encroaching on the land.
Ironically, in 1810, the British and the Spanish became allies against Napoleon's troops. According to a bilateral agreement between Spain and the UK, the Gibraltar Commanding Royal Engineer Sir Charles Holloway blew up 'the Lines' to prevent the fortifications from falling under French control.
At the start of the 20th century, the issue of tobacco smuggling prompted both sides to erect a fence, giving birth to the de facto border. In 1909, Britain decided to build a 2.1 metre high fence. Initially citizens could cross the border unhindered to visit family members on either side of the divide. In 1954, Spain began to impose various additional restrictions in response to news that Queen Elizabeth II would visit the Rock.
Gibraltar was effectively isolated by Francisco Franco when he erected the 'The Fence of Gibraltar' called the 'La verja de Gibraltar' in Spanish. The border was in retaliation to the Gibraltar Constitution Order of 1969. The fence ran east-west for a total of 1.2 kilometres and remained closed for 13 years and a half years.
The partial reopening of the border occurred on 15 December 1982. It was the result of years of negotiations between Spain's newly elected Socialist party and Margaret Thatcher's conservative government. Relinquishing the blockade still left tight restrictions and only allowed access to pedestrians - both Spanish citizens and inhabitants of Gibraltar. British and foreign tourists as well as cars and commercial vehicles were banned from crossing the border.
When in 1986 Spain wanted to join the European Community, Margaret Thatcher stated that Spain could not enter the Community "until the restrictions on the border between Spain and Gibraltar are lifted". Finally, free movement between Spain and Gibraltar started on 5 February 1985.
On 5 February 1986, the Gibraltar-Spain border happily became the focus of attention once again. To celebrate the first anniversary of the full reopening of the border, the first stage of the Andalusian road bicycle race, the Vuelta a Andalucía, ended in Gibraltar after the cyclists crossed 'The Fence.'