Theresa May said the UK's position on the sovereignty of Gibraltar has not changed following claims she caved in to Spanish demands for concessions over the future of the territory.
European Union leaders will give their seal of approval to the Prime Minister's Brexit deal at a summit on Sunday which had been threatened by the diplomatic row with Madrid.
Spanish Prime Minister Pedro Sanchez claimed the UK and European Union had agreed to its demands for guarantees over the status of Gibraltar in future negotiations.
Madrid's foreign minister Josep Borrell went further, saying the agreement is "highly positive for Spain" and "the most important" since the Treaty of Utrecht in 1713 under which Gibraltar was ceded to the UK.
(2/2) before the #EU and all diplomatic staff and civil servants who were part of Spain's negotiating team for their effort, dedication and professionalism, in order to achieve such a satisfactory result for our interests. @HablamosdEuropa@UeEspana
— Josep Borrell Fontelles (@JosepBorrellF) November 24, 2018
But Mrs May told reporters in Brussels: "The UK's position on the sovereignty of Gibraltar has not changed and will not change.
"I am proud that Gibraltar is British and I will always stand by Gibraltar."
The diplomatic spat which threatened to derail the Brexit process was resolved after a clarification about the legal position and emergency talks involving Mr Sanchez, European Council president Donald Tusk and European Commission president Jean-Claude Juncker.
A letter from the UK's ambassador to the EU Sir Tim Barrow confirmed the Withdrawal Agreement imposes no obligations regarding the "territorial scope" of future agreements – Spain wants to make sure it has a say over how any UK-EU trade deal applies to the Rock.
But the UK has also made clear it will negotiate future agreements on behalf of all territories for whose external relations it is responsible – including Gibraltar.
Mrs May said: "We have ensured that Gibraltar is covered by the whole Withdrawal Agreement and by the implementation period and we will always negotiate on behalf of the whole UK family, including Gibraltar, and in the future relationship we will stand up for their interests."
But Liberal Democrat Brexit spokesman Tom Brake claimed the Prime Minister had "caved in" and "appears to have cast the people of Gibraltar aside".
Following the resolution of the row, Mr Tusk sent out formal invitation letters to EU leaders for the summit, saying the Brexit deal reached by negotiators from the UK and Brussels "found the best possible compromise" and he would recommend that they approve it.
I will recommend that we approve on Sunday the outcome of the #Brexit negotiations. No one has reasons to be happy. But at least at this critical time, the EU27 has passed the test of unity and solidarity. https://t.co/N3EexasL2n
— Donald Tusk (@eucopresident) November 24, 2018
Mrs May also faced domestic difficulties as the Democratic Unionist Party held its conference in Belfast – with Boris Johnson making a guest appearance.
Chancellor Philip Hammond sought to reassure the DUP over its "understandable concerns" about the Northern Ireland backstop provisions aimed at preventing a hard border with Ireland.
But he warned there could be "economic chaos" if MPs reject the deal struck between the Government and Brussels.
He told BBC Radio 4's Today programme he believes the deal on offer is better for the UK than remaining in the EU, stressing it will help heal the divisions caused by Brexit.
"It's a way of leaving the European Union with minimum negative impact on our economy," he said.
"Economics is not the only consideration – we also have to look at the political healing process, bringing our country back together because countries that are disunited and divided are not successful countries."
With MPs including the DUP and scores of Tories from both the Remain and Leave wings of the party set to oppose the Brexit package, Mr Hammond issued a stark warning about the impact of rejecting it.
"If the meaningful vote is lost we are in uncharted territory," he said.
"We will be faced with potential economic chaos. I am sure we would get a very negative reaction from the business community, from investors, from the markets."
In her conference speech, DUP leader Arlene Foster said: "The reality is that if we are to secure a better outcome than is currently on offer, then the only option is to look beyond this current draft Withdrawal Agreement and work in the time ahead for an improved outcome."
Mr Johnson, viewed as a potential leadership rival to Mrs May, was given a rousing reception at the conference.
He said the UK is on the verge of "making a historic mistake", adding: "Unless we junk this backstop, we will find that Brussels has got us exactly where they want us – a satellite state."
He set out a series of demands, including a commitment in the Withdrawal Agreement for a "super Canada" trade deal, a provision to withhold "at least half" the £39 billion divorce bill until trade talks are concluded, and a dedicated Cabinet minister for no-deal planning.
Meanwhile, the Daily Telegraph reported the Home Office has drawn up plans to issue low-skilled migrants with 11-month visas "with restricted entitlements and rights" while they are living in the UK as part of the post-Brexit immigration system.
Alternative plans could allow EU migrants aged between 18 and 30 to live and work in the UK for two years, with a strict cap on numbers.
The Government will abolish the cap on highly skilled "tier 2" migrants entirely, the report said, with the plans set out in the week beginning December 3 – a week before the crunch Brexit vote is expected in the Commons.