All 27 European Union leaders have endorsed the Brexit deal at today's EU summit, urging the UK to get behind British Prime Minister Theresa May's package despite furious opposition in the British parliament.

"EU27 has endorsed the Withdrawal Agreement and Political Declaration on the future EU-UK relations," said Donald Tusk, European Council president, after less than an hour of the leaders' summit.

Speaking at a press conference after, Mr Tusk said: "Ahead of us is the difficult process of ratification as well as further negotiations.

"But regardless of how it will all end, one thing is certain: we will remain friends until the end of days. And one day longer."

European Commission president Jean-Claude Juncker said "it is a very sad day".

"A country leaving the EU doesn't give rise to the raising of Champagne glasses or applause. It is a sad day and everybody who spoke today during the European Council attempted to express their sadness.

"It was broadly shared, if not unanimously shared."

He acknowledged that "ultimately we did have a problem, a difficulty, with our Spanish friends" at the end of the process over Gibraltar.

"I would point out today that the agreement we have obtained here today is an agreement which is good for Spain, so we are with Spain," he said.

The 27 leaders adopted an official statement in which they committed "to take the necessary steps to ensure that the agreement can enter into force on 30 March 2019, so as to provide for an orderly withdrawal."

The statement also promised "as close as possible a partnership with the United Kingdom" after Britain leaves on 29 March, 2019, and thanked Michel Barnier, the bloc's Brexit negotiator. They urged the UK parliament to back the deal as well.

Earlier, Mr Juncker said that Brexit is a "tragedy" but the EU will not change its fundamental position in the event that the withdrawal treaty is rejected on the British side.

Speaking at an emergency summit of EU leaders in Brussels to formally adopt the Brexit treaty, the EU's most powerful official said that the Brexit treaty is the best possible deal for Britain.

Mr Juncker said the EU will not deal with the hypothetical case that the UK parliament might reject the deal.

EU chief negotiator Michel Barnier said this morning: "Now it is time for everybody to take their responsibility."

"This deal is a necessary step to build trust between the UK and the EU, we need to build in the next phase of this unprecedented and ambitious partnership. We will remain allies, partners and friends," said Mr Barnier.

A last minute agreement was reached over the weekend on how Gibraltar will be managed once a future EU-UK trade deal is negotiated.

Speaking at the summit, Taoiseach Leo Varadkar said he still regrets that the UK is leaving the EU, and that "the best outcome for Ireland and I think for Britain and the European Union would be for the UK to stay in the European Union, to stay in the single market and customs union. But we respect their decision not to do that."

"We spent two years trying to negotiate an agreement that protects our interests, our citizens and our economy, and I believe we have that," added Mr Varadkar.

Read more:
EU rules out UK role in foreign and defence decisions post-Brexit
'What's on the table is the only deal', says Varadkar
May urges MPs to back Brexit deal for 'brighter future'
More Brexit stories

Mrs May wrote a so-called letter to the nation in which she said the withdrawal agreement would work for the whole country - England, Scotland, Wales and Northern Ireland - whether people voted Leave or Remain.

On 19 June last year, David Davis, the Brexit secretary, arrived in Brussels to begin the divorce proceedings.

Now those negotiations will be formally closed. But it has been a gruelling journey with the path littered with ministerial resignations, failed initiatives and dashed expectations of how Brexit might unfold.

The UK is more divided than it has ever been, and even today's formal endorsement is only a pause before more bloodletting within the Conservative Party, and a widespread expectation that the House of Commons will reject the deal.

DUP leader Arlene Foster said that if Mrs May wants the party's continued support, it means removing the Irish backstop from the withdrawal agreement.

But at the Brussels summit, EU leaders have endorsed the withdrawal agreement and the political declaration which sketches out the future relationship.

The European Council also pledges to remain vigilant to ensure a number of issues are followed through, including reciprocal access to UK waters for European fishing fleets, and the Irish backstop, the issue which became the defining dilemma of the Brexit negotiations.

Reporting: Tony Connelly, Reuters, AFP, PA