The deal will almost certainly come with steep costs for both sides, leaving leaders in the extraordinary position of negotiating a split that they almost all believe will harm their citizens.
Some EU leaders said they felt today's deal was a tragedy.
The deal, approved unanimously by the remaining 27 EU leaders, would leave Britain in legal limbo - obligated to follow most EU rules but no longer a member - until the end of 2020, as leaders haggle over the relationship to come. The assent came after less than an hour of discussion.
"Today has been a historic day," Merkel said after the meeting, a rare and unusual gathering of European leaders on a chilly morning in Brussels. "My feelings are very divided. I feel very sad, but at the same time I feel a sense of relief."
British Prime Minister Theresa May, asked if she shared the unhappiness, said: "No, but I recognise that others do".
May said the British Parliament will now face "one of most significant votes Parliament has had in many years," and that she would campaign for it with all her heart.
"This is the deal on the table," she said. "It is best possible deal. It is the only deal."
Under the terms of the deal, Britain will face a US$50 billion bill to pay its financial commitments on its way out the door.
It will be tied to EU laws and regulations for years in some areas, and its ability to negotiate its own trade deals - a key demand of the Brexiteers who led a successful rebellion against the established order in 2016 - could be tightly limited.
But it will no longer be obligated to allow EU citizens to live and work within its borders, and May has sought to promote that as a major win, even as other leaders shake their heads about the situation.
"The cost we discussed in recent months is massive," said French President Emmanuel Macron. "Those who said to the British they would save several dozens or hundreds of billions pounds lied to them."
British and EU negotiators will still have to work out the terms of their future relationship, and although a 36-page declaration also approved today set out some of the guidelines, much remained unresolved, including Britain's freedom to control large parts of its own economy.
Arriving at this point in the divorce has been a struggle: 17 months of fraught negotiations, marked by non-stop bickering within May's own leadership team, including a string of high-profile resignations from her Cabinet.
May's headaches are far from over. Her limits as vote-wrangler will be tested in her own Parliament, where pro-Brexit MPs have hammered the plan as failing to break decisively enough from Brussels and pro-EU forces have condemned it as a self-inflicted wound that hurts British voters.
According to the British press, as many as 90 MPs of May's own Conservative Party have said they plan to vote against it, alongside members of the opposition Labour Party.
The plan seeks to avoid a hard border between the Republic of Ireland, which is remaining in the EU, and Northern Ireland, which will depart.
It also seeks to prevent an internal split between Northern Ireland and the rest of the United Kingdom.
To do so, the two sides agreed that if they fail to come up with a better plan before the end of Britain's transition period, London would remain locked inside the European customs union, obligated to respect most EU regulations on goods that would pass between the two sides, including tariffs with the rest of the world.
In addition to the divorce deal, May and her European counterparts approved a political declaration on the future relationship between the two partners.
Unlike the withdrawal agreement, which will be legally binding after it is approved by British and European parliaments, the political document is loosely worded and aspirational, an outline for future talks, which will likely take years to complete.
It contains a list of hoped-for outcomes on trade, customs inspections, tariffs, fisheries rights, aviation, and the ability of citizens to visit and live in the other's territory.
Even the vague aspirations, however, are likely to disappoint British business interests. For example, while May has long sought to replicate the "frictionless" trade that exists today between members of the European Union, a post-Brexit Britain will face "separate markets and distinct legal orders," according to the political declaration, while aligning with EU rules.
London's financial centre, one of the largest in the world, will also see its access to Europe diminished when it surrenders its "passport" rights to move money.
Boris Johnson, the former Foreign Secretary and lead campaigner for Brexit, said that Britain was "on the verge of a historic blunder." He said May's withdrawal deal surrenders too much power to Brussels.
What will happen to the withdrawal agreement if it is voted down by the British Parliament is unclear. May could put it up for a vote again. She could face a leadership challenge or new elections.
Britain could even re-run their referendum, although few analysts believe this is realistic.
Brexiteers want negotiators to return to Brussels to amend the deal, but European leaders have said that they have little room to improve it and that there is nothing more to talk about. They advised British MPs to take what is on the table.
The disagreements have left the two sides staring into the abyss, as British opponents to the deal say they want to come up with something better.
EU leaders say the alternative is a chaotic no-deal departure - a development that could ignite economic crisis and could even lead to shortages of medicine in Britain.
Europe has largely held united through the negotiations, vowing that if Britain leaves their club, it must no longer benefit from club benefits.
Leaders generally dislike the departure but now want to pin down the deal to free them to focus on other, more pressing problems such as populism, struggling economies and Russia.
Their main goal today appeared to be to try to move on from the bitter break-up.
"Nobody is winning. We are all losing because of the UK leaving," Dutch Prime Minister Mark Rutte said.
BREXIT AT A GLANCE
The May deal
- The Withdrawal Agreement negotiated by British Prime Minister Theresa May honours the UK commitment to pay its share of the European Union budget until it leaves the economic bloc.
- The deal includes a 21-month transition period, beginning in March 2019, which could be extended for another year or even longer.
The transition
- During the transition period, little would change as the UK and the EU negotiate their future trade and security relationship.
- Citizens on both sides would continue to move freely without a visa.
- The UK would continue to abide by all EU rules and regulations and obey the rulings of the European Court of Justice.
- Britain would no longer have its members serving in the European Parliament and other EU rule-making bodies.
The backstop
- In order to avoid a hard border between Northern Ireland and Ireland, a member of the EU, the two sides agree to a "backstop," a kind of insurance policy.
- This backstop means that if the two sides fail to achieve a future trade deal that would free both countries from the need for inspections, controls and tariffs at the Irish border, then the UK would remain under an EU customs union umbrella.
Brexiteer viewpoint
- The Parliament's "European Research Group," composed of hardline Brexiteers, who favour a decisive break from the European Union, issued a white paper outlining their objections to proposed Withdrawal Agreement.
- "The UK would hand over £39 billion of taxpayers' money with nothing guaranteed in return."
- "The UK would remain a 'rule taker' over large areas of EU law."
- "It would lock us in a Customs Union without the ability to leave."
- "It would creates internal borders within the UK, undermining the integrity of the Union."
- "The European Court of Justice would remain in control of the agreement and large areas of EU law directly effective in the UK."