After nine hours of talks at a Brussels summit on migration Europe's leaders managed to walk away with a deal.
Some of the pressure has now lifted from German Chancellor Angela Merkel's shoulders.
Her coalition partner, the Christian Social Union, which has threatened to shut Bavaria's border to migrants - something that could trigger the collapse of her three-month-old government as well as the EU's Schengen free-travel zone - gave the summit deal a cautious welcome.
EU states have now agreed to share out refugees arriving in the bloc on a voluntary basis and create "controlled centres" - essentially refugeee camps - inside the European Union to process asylum requests.
They've agreed to share responsibility for migrants rescued at sea, a key demand of Italy's new prime minister, Giuseppe Conte.
There was also agreement on tightening the EU's external borders and increase financing for Turkey, Morocco and other North African states to prevent migration to Europe.
And there was a financial promise to channel more aid to migrant producing countries.
In a final statement full of convoluted language designed to satisfy the divergent views, the leaders agreed to restrict migrant moves within the bloc but made clear virtually all of their pledges would be carried out on a "voluntary basis" by member states.
"Evertyhing is voluntary which is what Viktor Orban and Giuseppe Conte wanted," Ryan Heath, Political Editor, Politico news website said, referring to the leaders of Hungary and Italy.
There was no mention of whether to rescue migants though, and on Friday the Libyan coastguard reported abround a hundred were feated dead after their boat capsized.
The summit underscored how Europe's 2015 spike in immigration continues to haunt the bloc, despite a sharp drop in arrivals of people fleeing conflict and economic hardship in the Middle East and Africa.
French President Emmanuel Macron, who has sharply criticised Italy for refusing to allow a migrant rescue ship into its ports, said European cooperation had "won the day".
Fewer than 45,000 migrants have made it to the European Union this year, according to U.N. data, a sharp drop from 2015 when many thousands were entering on a daily basis.
But the political tremors are still being felt across Europe, with populist, anti-immigrant parties on the rise in many countries.
Ex-communist easterners, led by Poland and Hungary, are still refusing to accept a share of the new arrivals to alleviate the burden on countries such as Italy and Greece.