Leaders of the European Union aim to sign an agreement with Turkey in Brussels on Sunday that offers Ankara cash and closer ties with the EU in return for Turkish help in stemming the flow of migrants to Europe.
Aware of a sense of desperation in Europe for a solution to a crisis that is tearing the bloc apart following the arrival of close to a million people this year, Turkish President Tayyip Erdogan has been driving a hard bargain and diplomats said the 28 states had struggled through Saturday to agree a final offer.
Turkish Prime Minister Ahmet Davutoglu is due to meet the 28 EU national leaders for three hours from 4 p.m. (1500 GMT).
The Europeans, and none more so than German Chancellor Angela Merkel, are under pressure to manage the biggest influx of people since World War Two, the bulk of them to Germany, where Merkel is pushing hard for a Turkish deal. The crisis has helped populist opponents and set nations against each other, straining the open borders cherished by the Union's members.
Measures the EU has taken in recent months have as yet done little to control movements and while winter weather may lower the numbers for a few months, it is also worsening the plight of tens of thousands stuck by closing borders in the Balkans, piling further pressure on European leaders to find a solution.
Sunday's summit, called just days ago as Brussels tried to clinch a deal offered over a month ago, has been complicated by Turkey's downing of a Russian warplane on the Syrian border.
That has in turn complicated European efforts to re-engage with Moscow, despite a continued frost over Ukraine, in order to try and advance a peace in Syria that could both end the flight of refugees and contain Islamic State. The Islamist group's attack on Paris two weeks ago has also heightened public calls in the EU for more controls on people arriving from Syria.
By late on Saturday, after a further meeting of EU envoys in Brussels, diplomats said a common EU offer that they hope will secure Davutoglu's signature was agreed. It should be approved by governments on Sunday before the summit.
There remains a degree of nervousness, however, that Turkey could hold out for more - a nervousness heightened by Erdogan's decision not to attend himself but to send his prime minister.
"The Turks always negotiate to the last second," one senior EU diplomat said. "Why should this time be different?"
Cash on table
Europeans want Turkey to spend new EU money - some 3 billion euros ($3.2 billion) for the next year or two - on improving life for the 2.3 million Syrians now living in Turkey so that they are less likely to take to boats for nearby Greek islands.
The EU also wants Turkish authorities to make that journey more difficult and to keep out more of the Afghans and other Asians who cross Turkey on their way to Europe. It also wants to hold Turkey to commitments to take back people who successfully reach Greece but then fail in their claims for political asylum.
Turkey has pressed for more money. An original EU offer of 3 billion euros for refugee care over two years is now likely not to carry a clear timeframe as Ankara hopes to secure more.
Turks will be promised easier travel visas for Europe if they fulfil commitments on migrant flows in the coming year.
It will also win a pledge of "re-energised" talks on joining the EU, though with conditions to persuade EU states that do not want populous, Muslim Turkey ever to join, and also Cyprus, which wants Ankara first to help it reunite the island.
Diplomats said Turkey, whose decade-old EU accession talks have been stalled, would see talks on economic cooperation open shortly, but its demands for commitments from the EU to start talks on other issues such as human rights would remain on hold - satisfying Cypriot insistence it meet existing conditions.
Human rights concerns are unlikely to feature much in the talks on Sunday, diplomats said, despite calls from activists in Europe and Turkey for EU leaders not to ease pressure on Erdogan over issues such as media freedom because of the migrant crisis.
While EU leaders have pledged to continue to raise issues such as last week's new jailing of Turkish journalists and new complaints of oppression from minority Kurds, officials and diplomats say Europe's priority with Ankara for now will be getting Erdogan's help in slowing migrant movements.
A senior German official stressed on Friday, however, that Ankara also had much to gain from cooperation as it faces an angry Russia and hostility from Syria and Iran.