Media playback is unsupported on your device Media caption Theresa May: "I will make the case for this deal with all my heart"

EU leaders have approved an agreement on the UK's withdrawal and future relations - insisting it is the "best and only deal possible".

After 20 months of negotiations, the 27 leaders gave the deal their blessing after less than an hour's discussion.

They said the deal - which needs to be approved by the UK Parliament - paved the way for an "orderly withdrawal".

Theresa May said the deal "delivered for the British people" and set the UK "on course for a prosperous future".

Speaking in Brussels, she urged both Leave and Remain voters to unite behind the agreement, insisting the British public "do not want to spend any more time arguing about Brexit".

The UK is scheduled to leave the EU on 29 March 2019.

The EU officially endorsed the terms of the UK's withdrawal during a short meeting, bringing to an end negotiations which began in March 2017.

European Commission President Jean-Claude Juncker said anyone in Britain who thought the bloc might offer improved terms if MPs rejected the deal would be "disappointed".

But European Council President Donald Tusk, who broke the news of the agreement on Twitter, said he would not speculate on what would happen in such a situation, saying: "I am not a fortune teller."

The UK Parliament is expected to vote on the deal on 12 December, but its approval is far from guaranteed.

Labour, the Lib Dems, the SNP, the DUP and many Conservatives MPs are set to vote against.

Mrs May has appealed to the public to get behind the agreement - saying that although it involved compromises, it was a "good deal that unlocks a bright future for the UK".

Media playback is unsupported on your device Media caption Prime Minister Theresa May meets EU leaders after their endorsement of her Brexit deal

At a news conference in Brussels, she said the agreement would:

end freedom of movement "in full and once and for all"

protect the constitutional integrity of the UK, and

ensure a return to "laws being made in our country by democratically elected politicians interpreted and enforced by British courts".

The agreement, she added, would not remove Gibraltar from the "UK family" - a reference to a last-minute wrangle with Spain over the territory.

What has the EU decided?

Media playback is unsupported on your device Media caption Jean-Claude Juncker: "There are no smooth divorces"

The EU leaders have approved the two key Brexit documents:

The EU withdrawal agreement: a 599-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 Irish border open, if trade talks stall

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

There was no formal vote on Sunday, with the EU proceeding by consensus.

Mr Juncker said it was a "sad day" and no-one should be "raising champagne glasses" at the prospect of the UK leaving.

While it was not his place to tell MPs how to vote, he said they should bear in mind that "this is the best deal possible...this is the only deal possible".

His message was echoed by Irish Prime Minister Leo Varadkar who said "any other deal really only exists in people's imagination".

But Lithuanian President Dalia Grybauskaite suggested there were a number of possible outcomes if the UK Parliament rejected the deal, including an extension of the negotiations, or another referendum.

PM's message: 'This is all there is'

By Laura Kuenssberg, BBC political editor

It's a compromise. It was always going to be. It's not a happy compromise either. People on both sides of the Brexit argument are already screaming their protests.

And although the prime minister must be relieved, she didn't exactly say that she was pleased about the deal when I asked her at a news conference this lunchtime.

Instead, she said she was sure the country's best days are ahead.

But however she really feels about it - and with this prime minister it is hard to tell - her strategy for the next couple of weeks is crystal clear.

Her case? This is all there is.

What was the mood in the room?

No member states raised objections to the Brexit withdrawal deal and it was approved in a matter of seconds, according to a senior EU official.

Around seven leaders spoke in the session of the 27 member states, mostly to say this was a sad day and they wanted the future relationship with the UK to be as close as possible.

After Mrs May's address, roughly half of the leaders spoke. Several wished her good luck with the meaningful vote in Parliament.

No "what ifs" were discussed.

What happens next?

Media playback is unsupported on your device Media caption Foreign Secretary Jeremy Hunt appealed to so-called "Bobs" - people who he said are "bored of Brexit" - to support the agreement

Mrs May will now need to persuade MPs in the UK Parliament to back it.

She is expected to spend the next fortnight travelling the country trying to sell the deal before a parliamentary vote in the second week of December.

If MPs reject the deal, a number of things could happen - including leaving with no deal, an attempt to renegotiate or a general election.

Foreign Secretary Jeremy Hunt said the parliamentary arithmetic was "looking challenging" and warned "nothing could be ruled out" if Mrs May lost the vote, including the government collapsing.

He told the BBC's Andrew Marr that the UK was getting "between 70% and 80%" of what it wanted, while the agreement "mitigated" most of the negative economic impacts.

Asked if the UK would be better off than if it stayed in, he said the country would not be "significantly worse or better off but it does mean we get our independence back".

The agreement will also have to go back to the European Council, where a majority of countries (20 out of 27 states) will need to vote for it.

It will also need to be ratified by the European Parliament, in a vote expected to take place in early 2019.

What are Mrs May's critics saying?

Labour leader Jeremy Corbyn responded to Sunday's summit by calling the deal "the worst of all worlds".

He said his party would oppose it, but would work with others "to block a no deal outcome" and ensure "a sensible deal" was on the table.

Former Conservative leader Iain Duncan Smith said he would find it "very, very difficult" to support the agreement as it stood.

"I don't believe that, so far, this deal delivers on what the British people really voted for," he told Sky's Sophy Ridge show. "I think it has ceded too much control."

SNP leader Nicola Sturgeon - who wanted to stay in the EU - said it was a "bad deal" and Parliament should consider "better alternatives", such as remaining in the single market and customs union permanently.

And Democratic Unionist leader Arlene Foster - who wants to leave the EU - said her party's parliamentary pact with the Conservatives would be reviewed if MPs approved the deal.

She told the BBC's Andrew Marr show the agreement as it stood would leave Northern Ireland and the rest of the UK "still within European structures with no say in its rules".

Former PM Tony Blair, who backs another referendum, said the deal was "a dodo".