European Union leaders have agreed a common stance on a plan to send tens of thousands of migrants back to Turkey which they will put to Turkish Prime Minister Ahmet Davutoglu on Friday.
At late night talks in Brussels on Thursday, leaders were assured that the draft deal would not result in mass deportations and some differences were bridged over sweeteners to give Turkey in exchange for its help.
"The 28 have agreed on a proposal," French President Francois Hollande said. "It was late in the evening, but it has been done."
Desperate to ease the pressure placed on Europe's borders by the arrival of more than 1 million migrants in a year, the EU has turned to Turkey hoping to stem the flow of refugees into overburdened Greece.
The plan would essentially outsource Europe's biggest refugee emergency in decades to Turkey, despite concerns about its sub-par asylum system and human rights abuses.
Under it, the EU would pay to send new migrants arriving in Greece who don't qualify for asylum back to Turkey. For every migrant returned, the EU would accept one Syrian refugee, for a total of 72,000 people to be distributed among European states.
In exchange for the help of Turkey — home to 2.7 million Syrian refugees — the EU will offer up to 6 billion euros ($6.6 billion) in aid, an easing of visa restrictions for Turkish citizens and faster EU membership talks.
The summit chairman, EU Council President Donald Tusk, and the head of the executive Commission are scheduled to put Europe's terms for an agreement to Davutoglu early Friday for his endorsement.
If Davutoglu objects, the heads of state and government of the 28 EU nations will meet again to reconsider their position.
Human rights groups and leading EU legislators have decried the plan as a cynical cave-in, sacrificing universal rights to pander to a restless electorate fed up with hosting people who are fleeing war and poverty.
Even some leaders acknowledged the EU was walking a tightrope.
"It is on the edge of international law," Lithuanian President Dalia Grybauskaite said before leaders signed off on the tentative deal.
Some also criticized Turkey, complaining it was cynically trying to exploit the situation to win concessions well beyond its reach under normal circumstances.
"Turkey is really asking for a lot. I refuse to accept negotiations that sometimes resemble a form of blackmail," said Belgian Prime Minister Charles Michel.
Still, many see the deal with Turkey as perhaps the only way to halt the flow by land and sea, especially as the weather turns warmer, and prevent people from turning to unscrupulous smugglers.
Thousands have drowned in the Mediterranean trying to reach Greek or Italian islands. About 46,000 people are stranded in Greece after Macedonia shut its border to stem the flow along a popular migrant route through the Balkans. At least 14,000 are camped in the mud at a makeshift tent city in Idomeni, on the Greece-Macedonia frontier.
At one tent, 29-year-old Soukeina Baghdadi warmed herself by a fire shared with neighbors. Like many, she wants to move to Germany and is hoping that Europe's leaders can help.
"All the people here are waiting for the summit, waiting for the borders to open," she said.
The threat of a veto by Cyprus did not materialize, as the leaders' draft statement adroitly avoided explicit mention of any timeline on Turkey's EU membership. Turkey does not recognize the Mediterranean island's Greek-Cypriot government; a stance that has been a major obstacle to smooth accession talks.
When asked if he would veto a deal if he had to, Cypriot President Nicos Anastasiades told reporters: "If needed, yes."