Spain has claimed a major diplomatic coup after forcing Theresa May into giving written confirmation of their ‘veto’ over Gibraltar being covered by post-Brexit trade negotiations.

The Spanish move, which hands Madrid massive negotiating leverage over the future of the British overseas territory, came after days of diplomatic wrangling had threatened to derail tomorrow’s ‘seal the deal’ Brexit summit in Brussels.

After 48 hours of diplomatic arm-twisting, the British government conceded in writing that no part of the future agreement can apply to Gibraltar without the agreement of the Spanish government.

Spain’s foreign minister Josep Borrell said the agreement was “highly positive” for Spain and “the most important one since the Utrecht Treaty of 1713” when Gibraltar was ceded to the British Crown.

Spain’s prime minister, Pedro Sanchez, called the agreement “historic” and hinted that it would open the door to a redefining the status of Gibraltar and enable Spain to push for shared sovereignty of the Rock.

“Spain has achieved a historic triple lock with which it can enter definitive discussions with the UK over the future of Gibraltar over the next few years,” he said.

“We have gained sufficient guarantees to be able to seek the solution to a conflict between Spain and the UK that has lasted more than 300 years.”

Analysts said that Spain would use its ‘veto’ over the future relationship negotiations to extract a raft of deep concessions over Gibraltar, which it regards as a tax haven that must become more closely aligned with Spain.

“At some point Theresa May or future UK prime ministers will have to leave behind Gibraltar when the Spanish claims are legitimate,” said Ignacio Molina, a senior analyst at Elcano Royal Institute, a Madrid-based think-tank partly funded by the Spanish government.

Mr Molina said that Spain accepted it could not claim full sovereignty over Gibraltar against the will of its people who voted in a 2002 referendum to reject a proposal of joint sovereignty from the Tony Blair’s government by nearly 99 per cent.

But, he added, that did not mean Madrid would not use the huge leverage handed to it by Brexit to force it to make changes in areas of legitimate interest, like taxation where Gibraltar has no VAT and only 10 per cent corporation tax, compared to 25 per cent in Spain.

“‘Legitimate and reasonable’ means, corporate taxation, tobacco, gambling, some security issues, the airport, access to waters for fisheries, when any of these topics are included in general UK-EU future deals,” Mr Molina added.

“Compare corporate taxes in Gibraltar and the neighbor Spanish province. Compare average wealth and unemployment in both territories too. This will have to change.”

Gibraltar’s government released a statement saying that the “deep and unbreakable bonds” binding the United Kingdom and Gibraltar had not been diluted as a result of Brexit and that it would have “no effect on the British Sovereignty of Gibraltar and the waters that surround it.”

"Throughout our history we've stuck with Britain. After Brexit, we will stick with Britain in the future too. This is our most important relationship,” said Fabian Picardo, the Gibraltar chief Minister

“And as the UK establishes new trading and other relationships around the world, we look forward to the opportunities that will come from the benefits of our common language, our common law and the ties that bind us with the Commonwealth of nations around the world."

The Spanish ‘veto’ has been written into the Brexit negotiations since April 2017, but Mrs May’s remarks last week that she would negotiate for the “whole UK family” caused Spain to demand an explicit recognition of the veto.

Additional words added to the draft European Council minutes also re-state that Gibraltar “will not be included in the territorial scope” of the Brexit agreements, but that this did not rule out the UK and Spain concluding “separate” agreements.

Asked if Mrs May had been forced to climbdown, a government spokesman said: "No. This is the same position as for the first phase of the negotiations. We will negotiate outcomes which work for the EU and the whole of the U.K. family.”