The UK and the EU have reached a historic agreement paving the way for Brexit talks - all but deadlocked for several weeks - to move on to trade and future relations next year.

A joint report by the Commission and the UK government has been published.

The agreement upholds the Good Friday Agreement, guarantees no hard Irish border, and seals Northern Ireland’s status as an “integral part” of the UK.

It contains no figure for the UK’s divorce bill but sets out how it will be calculated. British contributions remain as now until the end of 2020, and continue beyond.

EU citizens are to have rights protected. European Court jurisdiction in the UK will end, but British courts must “pay due regard” to EU case law.

Theresa May called the deal “hard won”, Jean-Claude Juncker described it as a “compromise”, both Donald Tusk and Michel Barnier warned of difficulties to come.

Breakthrough at breakfast

British Prime Minister Theresa May made an overnight dash to Brussels for a meeting with European Commission President Jean-Claude Juncker in Brussels. At breakfast time on Friday they appeared together to announce that enough progress had been made on priority issues to move the negotiations forward.

"This is a difficult negotiation but we have now made a first breakthrough. I am satisfied with the fair deal we have reached with the United Kingdom. If the 27 member states agree with our assessment, the European Commission and our Chief Negotiator Michel Barnier stand ready to being work on the second phase of the negotiations immediately," Juncker said.

“Getting to this point has required give and take on both sides, and I believe that the joint report being published is in the best interests of the whole of the UK,” Theresa May declared.

The head of Juncker's Cabinet, Martin Selmayr, tweeted a picture of white smoke - a humourous reference to the Vatican's tradition of announcing a new pope.

It's understood that Theresa May spoke to all key players overnight, including the Irish Prime Minister Leo Varadkar, to secure agreement. This is only the first stage in a long process ahead to secure a final Brexit deal itself. This stage simply enables the talks to move forward.

'Bullet proof' for Ireland… ‘positive’ for Unionists

The agreement means that the objections of the UK government's allies, the Democratic Unionists (DUP) - which blocked the process earlier this week - have now been overcome.

Britain has now made substantive changes to an earlier proposed text for a deal with the EU, said the leader of the Democratic Unionist Party (DUP), Arlene Foster.

However, the DUP said more work was needed to clarify the arrangements given that Britain was committed to leaving both the EU's Single Market and the Customs Union.

Theresa May's office said she would continue to govern in the interests of all Northern Ireland and uphold the agreement that ended decades of sectarian violence in the province.

The Irish Prime Minister Leo Varadkar hailed a "politically bulletproof" agreement on his country's border with Northern Ireland, saying it pushed all sides towards a less economically damaging Brexit by Britain.

“We have achieved all that we set out to achieve in phase one of these negotiations… I am satisfied that sufficient progress has been made on the Irish issues, he told a news conference.

Irish Foreign Minister Simon Coveney said there was no scenario now in the context of Brexit that would result in a hard border between Northern Ireland and the Republic.

Financial settlement and citizens' rights

The joint report says both parties have agreed a methodology for working out the divorce bill, to be drawn up and paid in euros.

The agreement does not give a figure regarding the UK's obligations to the EU. However, a spokesman for Theresa May said it was expected to be between 35 billion pounds (40 billion euros) and 39 billion pounds (44.5 billion euros). The prime minister said it would be “fair to the British taxpayer”.

UK budget contributions continue as now through a two-year transition period after March 2019, and the UK will continue paying beyond this date for liabilities incurred beforehand.

EU citizens living in the UK and British people on the continent will have their rights to live, work and study protected. However, the campaign group British in Europe condemned a "grubby bargain" that was a "double disaster for British people living in Europe", saying it left unclear the rights to automatic residency rights and free movement beyond a transition period.

The EU has compromised on its previous demands concerning the future role of the European Court of Justice. “It will be British judges who say what is the law in the United Kingdom,” said Michel Barnier. UK courts can refer cases to Luxembourg but this will end after eight years.

What next?

EU leaders meet next Thursday for a European Council summit; their backing is needed for talks to advance. EU Council President Donald Tusk says he will ask them to give the green light.

Both Juncker and Tusk have said work on the second phase of negotiations could begin “immediately”. This would cover the transition period of about two years as requested by the UK, and Britain’s future relationship with the EU.

However, EU officials have said that London still needs to provide “more clarity” and that discussions with the UK government might not begin until February at the earliest.

What they have said

“We’ve now agreed a settlement that is fair to the British taxpayer… We will be able to invest more in our priorities at home, such as housing, schools and the NHS (National Health Service)” – UK Prime Minister Theresa May.

“While being satisfied with today’s agreement, which is obviously the personal success of Prime Minister Theresa May, let us remember that the most difficult challenge is still ahead. We all know that breaking up is hard. But breaking up and building a new relation is much harder” - EU Council President Donald Tusk.

“Our recommendation to the European Council is now to go to phase two of the negotiations and that will be an important statement by the European parliament in the resolution next week” – European Parliament Brexit co-ordinator Guy Verhofstadt.

"This deal is even worse than we expected. After 18 months of wrangling the UK and EU have sold 4.5 million people down the river in a grubby bargain that will have a severe impact on ordinary people's ability to live their lives as we do now" - British in Europe, coalition of British citizens in Europe.

"We're pleased to see those changes because for me it means there's no red line down the Irish Sea and we have the very clear confirmation that the entirety of the United Kingdom is leaving the European Union, leaving the Single Market, leaving the Customs Union" – Democratic Unionist Party (DUP) leader Arlene Foster.

"The strongest political commitment that exists in this document is the commitment that there will be no hard border... They are politically bulletproof. They're cast iron" – Irish Prime Minister Leo Varadkar.

“I am absolutely clear that any special arrangements for Northern Ireland must now be available to other nations of the UK – the Scottish government will not accept any arrangements which risk putting Scotland at an economic disadvantage” – Scotland’s First Minister Nicola Sturgeon.

“I think everyone understands that there is still much work for negotiators to do even if the European council decides to move into phase two of Brexit negotiations” – German government spokesman Steffen Seibert.

“The agreements reached between the European Union and the United Kingdom are good news and will minimize the costs of Brexit” – Spanish Prime Minister Mariano Rajoy.

“The British PM flying through the night to meet 3 unelected men and agree to every single one of their demands is humiliating for our country… This is not a deal, it’s a capitulation” – ex-UKIP leader Nigel Farage.

“Under Theresa May, we are leaving the European Union in name only… Theresa May has betrayed the country and the 17.4 million Leave voters”- Arron Banks (leading backer of pro-Brexit campaign).