The EU has finally got what it so desperately wanted: a solution to its migrant problem, or at least an agreement it perceives to be the solution. All migrants arriving illegally on European shores from this Sunday on are to be returned to transit country Turkey, starting on April 4.
"The most important part of this deal is that it will end the business model of people smugglers and contribute to securing the EU's external borders," German Chancellor Angela Merkel said at a press conference after the deal was done.
In return, the EU has agreed to speed up negotiations on Turkey's EU membership. Here's what you need to know about the quid pro quo.
Read our live coverage of how the deal was clinched earlier today.
Migrants to be returned to Turkey
From Sunday on, the EU may ship any migrant arriving in Europe via the Aegean Sea back to Turkey. In 2015, more than 1.26 million migrants arrived in the EU, and for nine months and nine summits devoted to the topic of migration, the bloc's 28 members failed to agree on a common position to stem the flow.
In return for any Syrian refugees the EU ships back from Greece to Turkey, the EU will take in one Syrian refugee currently in Turkey. This number, however, is to be capped at 72,000.
The European Union has agreed to speed up talks concerning Turkey's EU membership, meeting a key Turkish demand.
However, Turkish Prime Minister Ahmet Davutoglu didn't get everything he wanted: Turkey had requested that five so-called chapters of the EU accession talks be opened, but the EU has merely agreed to open one. That chapter - on budget and financial issues - is relatively less important than the rest. And perhaps more importantly: EU member Cyprus isn't able to veto this chapter.
Cyprus had been particularly opposed to making concessions to Turkey, as that would weaken its position in delicate talks about the island's reunification. Cyprus has been split in two ever since Turkey invaded the island's northern half in 1974.
The EU remains cagey about Turkey's demand that all visa restrictions on its citizens traveling to the Schengen passport-free travel zone be lifted by the end of June.
Without giving any guarantees, the EU has agreed to speed up its examination of whether Turkey is meeting the necessary requirements for visa liberalization. But EU leaders aren't prepared to let Turkey off the hook, insisting Friday that Ankara must meet all the necessary benchmarks.
Nevertheless, Turkey's prime minister was upbeat after the talks. "There are certain things Turkey needs to do," he said, "but we already meet 37 of the 72 requirements, and we hope to fulfill all of these requirements by the end of May."
This was a sensitive issue for both. On the one hand, not having to show passports at EU borders has become a matter of national pride for the Turks. On the other hand, several EU states don't want this issue to give a boost to far-right parties such as France's Front National.
Turkey will also get less than it originally asked for. Ankara had wanted an additional 3 billion euros ($3.33 billion) to better care for Syrian refugees, on top of the 3 billion euros already pledged by the EU in the fall.
But the EU has only said it will "speed up" the disbursement of these funds, and has vaguely held out the prospect of making more money available.
Challenges to implementing the deal
Resettling refugees has proven a very thorny issue among EU member states. So far, they have only committed to taking in 18,000 people. To fulfill the EU concession to take in up to 72,000 refugees from Turkey, a further 54,000 places will have to be found throughout the EU. Hungary and Slovakia have made it clear that these will not be found in their countries.
Administrating asylum requests and migrant returns
Greece is facing a particular challenge in putting into place the administrative and judicial infrastructure necessary to follow through with the deal.
Greek Prime Minister Alexis Tsipras said Greece needed some 2,000 additional lawyers and judges to deal with asylum requests and returns to Turkey, but he said his country could only muster 270.
EU members have declared they will help Greece by sending border guards, asylum experts and interpreters "at short notice."
'Dark day for humanity'
Human rights organizations fear there will be mass returns of migrants without a fair and individual assessment of asylum requests. After the deal was announced, NGO Oxfam called it a "further step down the path of inhumanity." Amnesty International echoed the harsh criticism.
EU Commission President Jean-Claude Juncker dismissed these concerns. "All refugees and asylum seekers will go through an individual scrutiny process, and they will be able to launch appeals," he promised.