EU summit chairman Donald Tusk said 40,000 migrants 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 June 25.
Earlier, Donald Tusk called on EU member states to share the burden of the boat loads of illegal migrants who have crossed the Mediterranean.
“Leaders agreed that 40,000 persons in need will be relocated from Greece and Italy to other states over the next two years,” Donald Tusk told reporters.
“Interior ministers will finalize 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 PM 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 and Nigeria.
More than 3 million people who fled the Syrian civil war are being housed in neighboring 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 June 25.
The final day of the summit on June 26 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 June 25.
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.2 billion 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.6 billion IMF debt repayment by June 30 or face default and a possible exit from the euro.
On June 25, 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 June 27.
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 June 25 and needed more time to assess it, Reuters reported.