European Union leaders have reached an agreement on migration after marathon talks at a summit in Brussels.
Italy - the entry point for thousands of migrants, mainly from Africa - had threatened to veto the conclusions of the entire agenda if it did not receive help on the issue.
In a compromise, new migrant centres are to be set up in EU countries on a "voluntary" basis.
They would determine who are "irregular migrants, who will be returned".
The relocation and resettlement of genuine refugees would also take place on a voluntary basis, the agreement says.
However, it was unclear which countries would host the centres or receive refugees.
The joint communique also speaks of restricting the movement of asylum seekers between EU states.
"After this European summit, Europe is more responsible and offers more solidarity," said Italian Prime Minister Giuseppe Conte. "Today Italy is no longer alone."
But German Chancellor Angela Merkel said more needed to be done to resolve disagreements.
What has been agreed?
In addition to the migrant processing centres, hosted by EU members on a voluntary basis, the 28 EU leaders also agreed several other measures:
Stay informed. Subscribe to our newsletter
Whose needs does the deal meet?
Italian Prime Minister Giuseppe Conte had earlier taken the rare step of blocking the conclusions of the joint communique until the leaders had settled the migration issue. Both Italy and Greece want other countries to share the burden.
German Chancellor Angela Merkel had said that the migration issue could be a defining moment for the EU - but she also needed the summit to avert a political crisis at home that could bring down her government.
Interior Minister Horst Seehofer, from her Bavarian coalition partner, the CSU, had given her a deadline of this weekend. He has threatened to start turning away migrants who have already registered elsewhere from the border in his home state.
Without the CSU, Mrs Merkel would lose her parliamentary majority.
It is unclear whether the measures agreed will be enough, and speaking to reporters at 05:00 local time (03:00 GMT), she acknowledged the EU still had "a lot of work to do to bridge the different views".