Turkey promised to help stem the flow of migrants to Europe in return for cash, visas and renewed talks on joining the EU in a deal struck on Sunday that the Turkish prime minister called a "new beginning" for the uneasy neighbors.
Leaders of the European Union met Turkish premier Ahmet Davutoglu in Brussels on Sunday to finalize an agreement hammered out by diplomats over the past month, as Europeans struggle to limit the strain on their 28-nation bloc from taking in hundreds of thousands of Syrian refugees.
A key element is 3 billion euros (2.1 billion pounds) in EU aid for the 2.2 million Syrians now in Turkey. The money is intended to raise their living standards and so persuade more of them to stay put rather than attempt perilous crossings to the EU via the Greek islands.
The final offer of "an initial" 3 billion euros represents a compromise between the EU, which offered that sum over two years, and Turkey, which wanted it every year. Now the money, as French President Francois Hollande said, will be paid out bit by bit as conditions are met, leaving the total payout unclear.
"As Turkey is making an effort to take in refugees — who will not come to Europe — it's reasonable that Turkey receive help from Europe to accommodate those refugees," Hollande told reporters. He added that the deal should also make it easier to check migrants arriving and keep out those who pose a threat, like Islamic State militants who struck Paris two weeks ago.
Also on offer to Ankara, which wants to revive relations with its European neighbors after years of coolness as it faces trouble in the Middle East and from Russia, is a "re-energized" negotiating process on Turkish membership of the EU, even if few expect it to join soon.
Many Turks could also benefit from visa-free travel to Europe's Schengen zone within a year if Turkey meets conditions on tightening its borders in the east to Asian migrants and moves other benchmarks on reducing departures to Europe.
"Today is a historic day in our accession process to the EU," Davutoglu told reporters on arrival. "I am grateful to all European leaders for this new beginning."
Aware of a sense of desperation in Europe for a solution to a crisis that has called into question its own cohesion and the future of its Schengen passport-free travel zone, Turkish President Tayyip Erdogan has driven a hard bargain.
The deal involves Turkish help, including through naval patrols and border checks, in handling the flow of migrants to the EU, expected to reach 1.5 million people this year alone.
"Results must be achieved in particular in stemming the influx of irregular migrants," a joint statement read.
"Both sides will, as agreed and with immediate effect, step up their active cooperation on migrants who are not in need of international protection, preventing travel to Turkey and the EU … and swiftly returning migrants who are not in need of international protection to their countries of origin."
Summit chairman Donald Tusk stressed that the meeting was primarily about migration rather than improving Turkish ties, which have been strained in recent years as Erdogan has used a powerful electoral mandate to consolidate his power. Critics say he has abused the rights of opponents, media and minority Kurds.
"Our main goal is to stem the flow of migrants," Tusk said, while insisting "this is not a simple, trivial trade-off".
The Europeans, 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. The crisis has helped populist opponents and set nations against each other, straining the open internal borders of the EU.
Before the summit itself, Merkel met leaders of some other EU states which have taken in many refugees — Sweden, Finland, Austria and the Benelux countries — and said afterwards they had discussed how they might resettle more of them directly from Syria rather than wait for families to reach the EU via dangerous smuggling routes across the Mediterranean.
She said they had discussed no figures. German media reports had spoken earlier of up to 400,000 Syrians being resettled.
Measures the EU has taken have done little to control migrant movements. 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.
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 complicated European efforts to re-engage with Moscow, despite a continued frost over Ukraine, in order to try to advance a peace in Syria that could end the flight of refugees and contain Islamic State. Davutoglu will remain in Brussels for a meeting with fellow ministers from NATO.
Irish Prime Minister Enda Kenny said tensions between Ankara and Moscow over the downing of the warplane were of "enormous concern". The EU's foreign policy chief Federica Mogherini said the incident should not affect the prospect of finding a political deal on Syria.
Islamic State's attack on Paris on November 13 has heightened calls in the EU for more controls on people arriving from Syria.
Merkel has forced the pace in securing a deal with Turkey that has left critics of Erdogan's human rights policies uneasy.
The German leader defended her stance: "If we are strategic partners, we must of course discuss openly with each other those issues on which we have questions, concerns or criticism."