Image copyright AFP/getty

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 has arrived in Brussels and held 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, who represents EU leaders on the world stage, 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 met the president of the European Commission, Jean-Claude Juncker, and Mr Tusk for talks on Saturday evening.

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.

Media playback is unsupported on your device Media caption What's in the political declaration?

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 in December. Labour, the Liberal Democrats, the SNP and the DUP have all said they will vote against the government's deal, as well as many Conservatives.

BBC News political correspondent Ben Wright has said Mrs May "faces an incredibly hard job" getting the deal passed by MPs.

Why was Spain unhappy?

Spain threatened to derail the Brexit deal over concerns about its role in future trade arrangements involving Gibraltar - a British Overseas Territory with 30,000 residents.

But the UK published a letter it had sent to Spain reassuring it over the withdrawal agreement.

After holding emergency talks with Mr Tusk and Mr Juncker, the Spanish prime minister dropped his threat.

Mr Sanchez said: "Gibraltar is excluded from the general negotiation of the European Union with the United Kingdom.

"This gives the chance to Spain to have direct negotiations with the United Kingdom over Gibraltar."

Media playback is unsupported on your device Media caption 'I will always stand by Gibraltar' - May

Spain's foreign minister Josep Borrell said the assurance was "the most important" development since the Treaty of Utrecht in 1713, which ceded Gibraltar to Britain.

But BBC Europe correspondent Kevin Connolly said that the UK's letter does not contain anything substantially different from the withdrawal agreement.

He said there was a suspicion that Spanish ministers were "showboating a little for the domestic electorate" on the eve of elections in Andalusia, in the south of Spain, where Gibraltar is a significant issue.

Theresa May said discussions with Spain have been "constructive and sensible" but that the UK's position on Gibraltar will not change.

She said: "I'm proud that Gibraltar is British and I will always stand by Gibraltar."

Media playback is unsupported on your device Media caption Why Gibraltar is British - in 60 seconds

Gibraltar's chief minister Fabian Picardo also played down Spain's claims about the UK's guarantees.

He said: "What you have heard from the Spanish prime minister was not a reflection of any new position, however much he tried to present it as such."

What did Boris Johnson say?

The former foreign secretary told Northern Ireland's Democratic Unionist Party (DUP) conference that the UK was on the verge of "making a historic mistake".

Mr Johnson said the UK had an "absolute duty to get this right" and there was still time to work for a better deal.

Media playback is unsupported on your device Media caption Boris Johnson told the DUP conference that agreeing to the Brexit deal would be an historic mistake

Mrs May relies on the support of the DUP's 10 MPs in key votes because she does not have a majority in the House of Commons.

The DUP has threatened to look again at the agreement with the Conservatives if the Brexit deal gets through Parliament.

But Mr Johnson said it was "absolutely vital that we keep this partnership going" to avoid Labour coming to power.

The DUP opposes the Brexit deal because of the "backstop" - the back-up plan to make sure a hard border between Northern Ireland and the Republic of Ireland never happens.

It will only come into effect if the UK and EU fail to agree a long-term trade deal. But the backstop would mean that Northern Ireland - but not the rest of the UK - would still follow some EU rules on things such as food products.

Please upgrade your browser Your guide to Brexit jargon Enter the word or phrase you are looking for Search

DUP leader Arlene Foster told her party conference that the prime minister had not been able to guarantee that the backstop would not have to be used.

She urged the government to secure a better deal for Northern Ireland, adding: "The choice is not between this deal and no deal, despite what the government spin machine may say."

What else has the government said?

Chancellor Philip Hammond insisted that the prime minister's Brexit deal is better than remaining in the EU.

He said the deal respected the result of the 2016 referendum and offered "the best compromise possible".

He added that he was hopeful of a solution with the DUP.

Media playback is unsupported on your device Media caption Michael: "What in your honest opinion is better for the UK, your deal or the deal we had if we stayed in the EU?"

On Friday, the PM said the UK should not hope for a "better deal" from the EU if MPs reject her Brexit agreement.

But Mrs May declined to say whether the UK would be better off outside the EU, saying only it would be "different".