Brussels - It has long been Northern Ireland that has bedevilled efforts to negotiate an orderly Brexit, but now another British territory has emerged to haunt the talks: Gibraltar.
With the hours counting down to Sunday's summit to sign an accord on overseeing Britain's departure form the European Union, Spain has threatened to bring matters to a halt.
"As a country, we can't conceive that what will happen with the future of Gibraltar will depend on a negotiation between Britain and the European Union," Prime Minister Pedro Sanchez said.
"As a consequence, today, I regret to say that a pro-European government like Spain's would vote no to Brexit unless there are changes," he told business leaders in Madrid on Tuesday.
In Brussels, EU officials and diplomats from member states are racing to finalise two texts: the Brexit divorce agreement and a parallel political declaration about future EU-UK ties.
The former has been approved by British premier Theresa May's cabinet and by the European Commission. It is seen here as all but ready and preparations continue apace for Sunday's signing.
But Spain has a problem with the text and wants it fixed. Briefly put, the withdrawal deal does not explicitly state that Madrid has a veto on future relations between the EU and Gibraltar after Brexit.
In April 2017, when Brussels and London began the marathon task of negotiating the terms of Britain's departure under Article 50 of the EU treaty, the guidelines were clear.
"After the United Kingdom leaves the Union, 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," the EU said.
Now, however, the formal withdrawal agreement on the table appears to suggest that, after the 21-month transition period post-March 29, relations will be decided simply by London and Brussels.
- 'Best endeavours' -
Article 184 of the deal binds the European Union and the United Kingdom to "use their best endeavours, in good faith and in full respect of their respective legal orders" to meet the agreed goals.
This seems to be enough for British negotiators, who insist that the Withdrawal Agreement covers Gibraltar.
"The PM has been clear that we will not exclude Gibraltar... from our negotiations on the future relationship. We want to get a deal that works for the whole UK family," a spokesperson said.
Spain is not convinced.
Foreign minister Josep Borrell has been in Brussels this week pressing EU negotiator Michel Barnier to remove the alleged "ambiguity" of Article 184 and confirm Spain's de facto veto.
European officials are loathe to reopen the withdrawal text, which coul stiffen resistance from British anti-Europeans or allow other states to pile in with last-minute special requests.
Instead, Borrell has suggested that language on Gibraltar be included in the 20-page political declaration on future ties that will be approved alongside the legal withdrawal treaty.
On Tuesday, Sanchez had a phone conversation with EU Commission president Jean-Claude Juncker -- who sees May on Wednesday -- and plans to talk to EU Council president Donald Tusk.
"We are aware of the Spanish government's problems and we are working on it," Commission spokesperson Margaritis Schinas said.
A strategic port on Spain's southern shore at the mouth of the Mediterranean, Gibraltar -- known by locals as The Rock -- has been governed by Britain since the 1713 Treaty of Utrecht.
Map and factfile on the British Overseas Territory of Gibraltar
Many Spaniards living in the poor surrounding Andalusia region commute into Gibraltar to work.
Since the Brexit referendum in June 2016, Spain's position on Gibraltar has been through a series of evolutions.
Initially it said it would seek co-sovereignty over it.
Later it played down the issue, but now -- with Brexit day looming -- it appears to be trying to squeeze out concessions.
- EU 'working on it' -
"It's no surprise that we are seeing the Spanish government raise issues at the last minute," complained Gibraltar's chief minister Fabian Picardo.
"The language of vetoes and exclusions should be the language of the past. It has no place in the modern Europe of today."
Madrid has traditionally accused this six-square-kilometre (1,500 acre) rock, home to 30,000 people, of being a tax haven and hub for tobacco smugglers.
It has demanded shared management of its small airport and an exchange of tax data with what the United Nations regards as a non self-governing territory.
After the Brexit referendum, in which Gibraltarians voted massively to stay in Europe while mainland Britain voted out, London and Madrid began bilateral talks on matters of disagreement -- but not of sovereignty.
Madrid wants to resolve these issues before the end of the post-Brexit transition period initially foreseen as December 31, 2020.
Keeping its veto on any EU decision on Gibraltar would give it leverage in these talks -- unless it is not made explicit in this week's agreements.
Gibraltar: a self-governing British overseas territory
In this, Madrid -- traditionally a supporter of the European Commission's policies -- has surprised many in Brussels.
"The Spaniards are serious, it is not a joke, but we are going to find a solution", said one European diplomat.
Spanish officials feel that their cooperative attitude on other issues gives them a strong base to make this claim.
"It is not exorbitant at all, we have special legitimacy to ask for it," a Madrid government source told AFP.
By Toni Cerdà