For more than three centuries, the territory of Gibraltar at the southern tip of the Iberian Peninsula has been a touchstone in relations between the United Kingdom and Spain. Now, with Britain having served notice that it formally wants to leave the 28-member European Union, Gibraltar is once again at the forefront.

For last year’s referendum on Brexit, then UK Prime Minister David Cameron offered the residents of the British overseas territory a vote on staying or leaving the EU. Gibraltarians voted to Remain, with 96 per cent choosing to stay in the EU. Just 4 per cent — 823 voters compared to more than 19,200 — opted to vote Leave.

The scale of the Remain vote was hardly surprising — the tiny territory’s booming economy is built on offshore financial services, e-commerce and hosting servers for gambling websites and portals. But there is a reality too that Gibraltar must have open access and free movement of people and goods with Spain. Nearly half of its entire workforce are Spanish and other EU passport holders who commute cross across what is Britain’s shortest land border with Europe. Its other is the frontier between Northern Ireland and the Republic of Ireland to the south.

But while Gibraltarians voted overwhelmingly to Remain, a majority of Britons voted to Leave, setting Brexit in place. On March 29, UK Prime Minister Theresa May gave notice of Britain’s activation of Article 50 of the Lisbon Treaty, setting the clock ticking on a two-year negotiation process on reaching a final divorce agreement between the London government and the other 27 members of the EU.

Since then, however, Gibraltar’s fate has become something of a political football between the May government, hardline British jingoists and the government in Madrid.

On June 24, as Gibraltarians conducted a social media witch hunt to track down the 823 who dared vote to Leave, Spain’s then foreign minister, Jose Manuel Garcia Margallo, said the Brexit result had hastened the day when the Spanish flag would fly over the territory — fighting words, considering that residents of the territory had twice rejected rejoining Spain in two separate referendums, in 1967 and the latest in 2002.

Fifteen years ago, only 187 voted to rejoin Spain, with 17,900 voting for the status quo. That has been in effect since the Treaty of Utrecht in 1713, which ceded the six square kilometres to the British Crown “in perpetuity”.

At the centre of the dispute between Madrid and London is an error of omission by May in the letter presented to Brussels laying out the reasoning and terms of Britain’s departure. It made no mention of Gibraltar. Given that the Brexit result was an unforeseen, unsavoury and unheralded surprise to British officials, their focus since then has been on formulating an exit strategy. Gibraltar had slipped through the cracks.

For jingoists in Westminster who hold a belief that Britain is indeed great and it still rules the waves, May needed to be held to account. Asked about Britain’s commitment to Gibraltar, May told the House of Commons the UK was “absolutely steadfast in our support of Gibraltar, its people and its economy”, adding: “We have been firm in our commitment never to enter arrangements under which the people of Gibraltar would pass under the sovereignty of another state against their wishes, nor to enter into a process of sovereignty negotiations with which Gibraltar is not content.”

The Article 50 letter was “a notification in relation to our withdrawing from the European Union”, May said. “Gibraltar is not a separate member of the EU, nor is it a part of the UK for the purposes of EU law, but we are clear that it is covered by our exit negotiations.”

Margallo’s replacement, the Brussels veteran Alfonso Dastis, seems to have the support of the rest of his EU colleagues when it comes to the opening negotiating position for Brexit talks, presenting London with the choice of reaching agreement with the Spaniards about Gibraltar’s future or exposing its citizens to economic peril by pushing the territory outside any EU-UK trade deal.

The announcement came towards the end of a nine-page draft document sent by the European Council president, Donald Tusk, to member states outlining negotiating guidelines for the upcoming Brexit talks. The guidelines, which will be refined at a summit of EU27 leaders at the end of April, ruled out talks on Britain’s future relations with the EU until “sufficient progress” had been made on agreeing the UK’s exit bill, securing citizens’ rights and dealing with Ireland’s border.

It says that once the UK leaves the bloc “no agreement between the EU and the United Kingdom may apply to the territory of Gibraltar without the agreement between the Kingdom of Spain and the United Kingdom”.

Dastis further infuriated the British when he said that Spain would look favourably on any application by an independent Scotland to rejoin the EU. With separatist sentiment still brewing in Spain’s Catalan region, Madrid had been previously loathe to mention the ‘independence’ word.

One former British minister, Lord Michael Howard, has gone so far as to suggest that Prime Minister May would go to war with Spain over Gibraltar, much as former Prime Minister Margaret Thatcher did with Argentina over the Falklands 35 years’ ago.

The ironic note in all of Spain’s political manoeuvring over Gibraltar is that it has remains steadfastly quiet over its two Mediterranean enclaves on Morocco’s shores. Ceuta is just 30km to the south of Gibraltar, and Madrid has no intention of giving up its claim on the enclave it has held since 1580. It has held Melilla, 300km to the east on Morocco’s coast, since 1497.

Gibraltar, Ceuta and Melilla — all duty-free havens, are owned by countries across the sea but claimed by the sovereign nation that surrounds them. And with citizens who want to stay as they are.