So what does today's Brexit agreement mean?
There will be no hard border with Northern Ireland/Ireland
The UK will pay about £40billion to leave and will continue to pay towards the EU until 2020
EU citizens living in the UK and vice versa will have their rights to live, work and study protected for now
The European Court of Justice will continue to have a role in overseeing rights for eight years after Brexit
The UK will still leave the Customs Union and Single Market after the transition period and freedom of movement 'as we know it' will end
The size of the so-called "divorce bill" emerged after European Commission president Jean-Claude Juncker announced that he is recommending leaders of the remaining 27 EU states give a green light to the start of trade talks next Thursday.
The breakthrough was hailed by Prime Minister Theresa May as "a hard-won agreement in all our interests", while European Commission president Jean-Claude Juncker said it represented "sufficient progress" for negotiations to move on to their second phase.
In dramatic pre-dawn scenes, Mrs May and Brexit Secretary David Davis flew to Brussels to confirm with Mr Juncker the text of a joint document setting out proposals on the key divorce issues of citizens' rights, the Irish border and Britain's exit bill.
The estimated Brexit bill is significantly lower than suggested by previous leaks, which put it at £50 billion or more.
It covers Britain's share of the EU's budget up to the end of 2020, as well as outstanding debts and liabilities for items such as the pensions of staff at European institutions.
It will be paid over several years and the exact figure is unlikely to be known for some time.
The Commission's announcement that trade talks can begin was welcomed by business leaders, who had warned that companies would begin activating plans to move staff and activities abroad if no progress was made by Christmas. The pound rose on the announcement.
Senior Cabinet Brexiteers Boris Johnson and Michael Gove gave their public blessing to the deal.
The Foreign Secretary - who previously said the EU could "go whistle" for any excessive financial demands - congratulated the PM for her "determination" in reaching the agreement, while Mr Gove described it as a "significant personal political achievement for the Prime Minister", which would make more money available for the NHS.
The final details were thrashed out in the early hours of Friday by Mrs May and Democratic Unionist Party leader Arlene Foster, who blocked a previous version of the agreement on Monday with her last-minute objection to provisions she feared would create a customs border between Northern Ireland and the mainland.
Mrs Foster said "substantial changes" to the text would mean there was "no red line down the Irish Sea" and no "special status" for Northern Ireland.
The joint report published by Mrs May and Mr Juncker says that in the absence of an overall trade deal, the UK will maintain "full alignment" with elements of the EU single market and customs union which support the economy of the island of Ireland and the Good Friday Agreement.
In a crucial passage, which appears to have been added to satisfy DUP concerns, it says "no new regulatory barriers" will be allowed between Northern Ireland and the rest of the UK, and that the province's businesses will continue to have "unfettered access" to the UK internal market.
In a provision likely to spark concerns among some backers of Brexit, the document says the European Court of Justice will continue to have a role overseeing the rights of EU citizens in the UK for eight years after Brexit.
It says the UK will be required to continue contributions to the EU budget up to the end of 2020 "as if it had remained in the Union", and will be liable for its share of outstanding financial commitments and liabilities up to that date.
The financial settlement "will be drawn up and paid in euro".
In a Brussels press conference Mrs May said the process of arriving at a withdrawal deal "hasn't been easy for either side", but the agreement represented a "significant improvement" on the text she was preparing to sign off on Monday.
Provisions on citizens' rights would allow EU nationals in the UK "to go on living their lives as before", while the financial settlement would be "fair to the British taxpayer" and the agreement on Ireland would guarantee there would be "no hard border" between Northern Ireland and the Republic.
"I very much welcome the prospect of moving ahead to the next phase, to talk about trade and security and to discuss the positive and ambitious future relationship that is in all of our interests," said Mrs May.
Mr Juncker said Brexit was a "sad" development, but added: "Now we must start looking to the future, a future in which the UK will remain a close friend and ally."
He and Mrs May shared "a joint vision of a deep and close partnership", he said.
European Council president Donald Tusk confirmed he has sent the EU27 proposed guidelines for a new mandate for chief negotiator Michel Barnier to begin discussions on the transition period, as well as "exploratory talks" on the trade relationship.
He called for "more clarity" from the UK over its hopes for trade relations.
Under his proposals, during the transition period of around two years after March 2019, the UK would be required to respect EU law - including any new laws passed by the EU27 without British involvement - and to observe its budgetary commitments and the judicial oversight of the ECJ.
"While being satisfied with today's agreement, which is obviously a personal success for Prime Minister Theresa May, let us remember that the most difficult challenge is still ahead," Mr Tusk said.
"We all know that breaking up is hard, but breaking up and building a new relation is much harder.
"Since the Brexit referendum, a year and a half has passed. So much time has been devoted to the easier part of the task, and now to negotiate the transition agreement and the framework for our future relationship we have de facto less than a year."
Irish premier Leo Varadkar, who held telephone talks with Mrs May on Thursday as the details of the deal were hammered out, said it was a "significant day" for Ireland, which had "achieved all that we set out to achieve in phase one of these negotiations".
Shadow Brexit secretary Sir Keir Starmer said the development was "encouraging", but added: "Theresa May must seriously reflect on her approach to the negotiations so far."