EU leaders holding late-night talks in Brussels have agreed to relocate tens of thousands of migrants who have arrived in Italy and Greece.
Summit chairman Donald Tusk said 40,000 would be relocated to other EU states over the next two years.
However, there will be no mandatory quotas for each country.
The Greek debt crisis was also on the summit’s agenda. Greece and its international creditors remain deadlocked after talks on Thursday.
Earlier, Mr Tusk called on EU member states to share the burden of the boat loads of illegal migrants who have crossed the Mediterranean.
New figures from the UN refugee agency UNHCR show that 63,000 migrants have arrived in Greece by sea this year and 62,000 in Italy.
“Leaders agreed that 40,000 persons in need will be relocated from Greece and Italy to other states over the next two years,” Mr Tusk told reporters. “Interior ministers will finalise the scheme by the end of July.”
Leaders also agreed to resettle another 20,000 refugees who are currently outside the EU. French President Francois Hollande said he expected most of them to be Syrians and Iraqis, AP reported.
Details of where the refugees will go have yet to be decided.
However, the UK has opted out of the scheme and nations in eastern Europe have refused to accept set quotas, so it will be only voluntary. This angered Italy’s Prime Minister Matteo Renzi, who called the plan “modest”.
Hungary, which has seen thousands of migrants cross its border by land, and Bulgaria, one of the EU’s poorest countries, have both been granted exemptions.
Italy has sought more help from its EU partners to handle the thousands of migrants arriving by sea, many of whom are fleeing war and poverty in countries such as Syria, Eritrea, Somalia.
More than three million people who fled the Syrian civil war are being housed in neighbouring countries – far more than the EU has taken in.
The migrant crisis has been high on the agenda for the EU summit, which opened on Thursday.
The final day of the summit on Friday is due to focus on security issues, namely the Ukraine crisis and tensions with Russia.
Meanwhile, the impasse in the Greek debt talks threatened to overshadow the summit, with two hours of unscheduled talks on Thursday.
Only once agreement on economic reforms is reached between Greece and its creditors – the European Commission, the European Central Bank (ECB) and the International Monetary Fund (IMF) – will the final €7.2bn tranche of bailout funds be released to Greece.
EU President Donald Tusk said European leaders are pushing for a weekend deadline for a deal to be reached, tweeting: “Another Eurosummit is not foreseen. Leaders expect the Eurogroup to conclude this process at their meeting on Saturday.”
Cash-strapped Greece must make a €1.6bn (£1.1bn) IMF debt repayment by Tuesday or face default and a possible exit from the euro.
On Thursday, a meeting of eurozone finance ministers also broke up without progress on the issue.
It was the fourth time in a week that the Eurogroup had met in an attempt to prevent a Greek debt default. They will meet again on Saturday.
German Chancellor Angela Merkel said that meeting would be “decisive” in finding a solution.
IMF head Christine Lagarde said lenders had been presented with a counter-proposal by the Greek parties “at the last hour” on Thursday and needed more time to assess it, Reuters reported.
Also during Thursday’s talks, UK Prime Minister David Cameron outlined his plans to renegotiate the terms of Britain’s membership of the EU.
Mr Tusk said EU leaders should consider British concerns but “only in a way that is safe for all of Europe”.