Prime Minister Pedro Sánchez has said Spain will reject the draft Brexit withdrawal deal without a clarification of the text on future talks on the status of Gibraltar.
Spain maintains a claim to the peninsula, ceded to the British crown under the 1713 Treaty of Utrecht.
It wants to ensure that future EU talks with the UK do not cover Gibraltar.
"As things stand today if there are no changes regarding Gibraltar, Spain will vote no on Brexit," said Mr Sánchez.
Throughout the Brexit negotiations, Spain - along with Ireland and Cyprus - has conducted separate talks with the UK about specific border issues.
On Monday Spanish Foreign Minister Josep Borrell said that the draft Brexit deal had failed to make clear that talks on Gibraltar were "separate negotiations" and not part of future talks between the UK and EU.
Mr Sánchez added his weight to those remarks on Tuesday at a forum in Madrid, emphasising that any future negotiations on Gibraltar had to be bilateral.
"As a country we cannot assume that whatever happens in the future with Gibraltar would be negotiated by the UK and EU - it will have to be negotiated between Spain and the UK," he said.
What is Spain's problem with the Brexit text?
Article 184 of the draft Brexit deal says the EU and the UK will seek to "negotiate rapidly the agreements governing their future relationship" between the official day of withdrawal on 29 March 2019 and the end of a transition period in December 2020.
But Spain believes the article in question is ambiguous and wants to ensure that this does not apply to the future of Gibraltar. It insists on its future right to discuss the status of the peninsula bilaterally with the UK, and is seeking clarity that this draft deal will allow it to do so.
Asked about the Spanish objection to Article 184, a European Commission spokesman said they were aware of Spain's concerns. He said the EU's position on Gibraltar had been made clear in April 2017 guidelines, that after Brexit no agreement between the EU and UK could apply to Gibraltar without the agreement of the UK and Spain.
Gibraltar's Chief Minister Fabian Picardo accused Spain of adopting a "well-known tactic" of raising issues at the last minute. He said Spain's position "does little to build mutual confidence and trust going forward".
Our press release on the matters raised this morning in Brussels in respect of the Withdrawal Agreement. pic.twitter.com/MywdmT12xZ— Fabian Picardo (@FabianPicardo) November 19, 2018
A spokesperson for UK Prime Minister Theresa May said the draft deal covered Gibraltar as well as "the other overseas territories and the crown dependencies".
"We will get a deal that works for the whole UK family."
Why Madrid is making its voice heard
By Gavin Lee, Europe reporter
Spain and Britain have been running parallel negotiations over the future of Gibraltar, alongside the main EU-UK Brexit negotiations. Those talks have led to a "protocol" being agreed and three Spanish-British committees being set up to tackle tobacco smuggling, oversee cross-border workers rights, and co-operate on environmental protection and border control.
There seemed to be no drama on the horizon and the Spanish prime minister told me a few weeks ago he had "no significant concerns over Gibraltar", that the "behaviour of the British government was good" and an agreement could be reached.
So what has changed?
The Spanish government says that its "bone of contention" is with one specific article in the draft Withdrawal Agreement that was only added last week, just before it was signed off by the European Commission, and wasn't seen by Spanish negotiators.
A senior Spanish diplomat told me that Spain wanted the following words (or similar) added to Article 184: "This does not apply to Gibraltar, which will be subject to bilateral talks between the UK and Spain."
Underlying all of this is the fact that Spain still disputes that Gibraltar as a British overseas territory. Spanish officials refer to the rock as a "British colony" and, although the Spanish government isn't seeking to use the Brexit talks to push that claim, it is making it clear that any decision over the future of Gibraltar can only happen with the approval of Madrid.
Though Spain ceded the peninsula under the 1713 treaty, it has tried several times to regain control over it.
A referendum in the territory in 1967 saw 99.6% of residents vote to remain British. A proposal for joint sovereignty was also decisively rejected by Gibraltarians in a 2002 vote.
Spain closed its border with Gibraltar after the 1967 vote and did not fully reopen it until 1985, the year before Spain joined the European Economic Community - the forerunner of the EU.
Gibraltar in numbers
- Gibraltar has a population of 33,600 and 7.7 million visitors a year
- Financial services and online gaming make up about 40% of the economy and account for nearly a quarter of jobs there
- It has its own tax system and attracts businesses with low tax rates
- Although there are exceptions, the general corporate tax rate in Gibraltar is 10%, while in Spain it is 25%
- Gibraltar has a considerably higher GDP per capita than either the UK or Spain.