European Council President Donald Tusk has recommended that the EU approve the Brexit deal at a summit on Sunday.
It comes after Spanish PM Pedro Sanchez received assurances from the UK government over Gibraltar, and dropped his threat to boycott the summit.
He said he had received the written guarantees he needed over Spain’s role in the future of the British territory.
UK Prime Minister Theresa May flies into Brussels later to hold talks with top EU officials, ahead of the summit.
Meanwhile, former UK Foreign Secretary Boris Johnson said the UK would become a “satellite state” under the deal.
The UK is scheduled to leave the EU on 29 March 2019.
The terms of the UK’s withdrawal have been under negotiation since June 2016 following a referendum in which 51.9% voted to leave the EU.
Even if the EU approves the deal, it still has to be passed by the UK Parliament, with many MPs having stated their opposition.
Spain had raised last-minute objections ahead of the summit about how the issue of Gibraltar had been handled in the Brexit talks so far.
But EU leaders secured a compromise with the Spanish prime minister, who said that Europe and the UK “had accepted the conditions set down by Spain” and so would “vote in favour of Brexit”.
Mr Tusk said he recommended “that we approve on Sunday the outcome of the Brexit negotiations” in a letter to members of the European Council.
He added: “No-one has reasons to be happy. But at least at this critical time, the EU 27 has passed the test of unity and solidarity.”
What will happen at the summit?
Mrs May will meet the president of the European Commission, Jean-Claude Juncker, and Mr Tusk for talks later.
Then on Sunday, EU leaders will meet for the special Brexit summit. They will be asked to approve two key Brexit documents:
- The political declaration, which sets out what the UK and EU’s relationship may be like after Brexit – outlining how things like UK-EU trade and security will work
- The EU withdrawal agreement: a 585-page, legally-binding document setting out the terms of the UK’s exit from the EU. It covers the UK’s £39bn “divorce bill”, citizens’ rights and the Northern Ireland “backstop” – a way to keep the border with the Republic of Ireland open, if trade talks stall.
There is no formal vote on Sunday but the EU expects to proceed after reaching a consensus.
What happens afterwards?
If the EU signs off the withdrawal deal, Mrs May will then need to persuade MPs in the UK Parliament to back it.
A vote is expected to happen in December.