The Brexit deal follows more than 18 months of negotiations between the two sides, which began when the UK triggered Article 50 in the wake of the 2016 referendum.
The UK is scheduled to leave the EU on March 29, 2019.
The UK Parliament is expected to vote on the deal in early December but its approval is by no means guaranteed, with Labour, the Lib Dems, the SNP, the DUP and many Conservatives lawmakers set to vote against.
UK’s PM Theresa May has appealed to the public to get behind the agreement, arguing it is the best deal she could have struck and honors the result of the Brexit referendum.
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.
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,” 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.
Donald Tusk’s government has won a parliamentary vote of confidence sparked by a scandal over leaked tapes of Polish senior officials.
PM Donald Tusk had told parliament that without a pledge of majority support he would not be able to effectively represent Poland in the EU.
The apparently secret recordings have been released by Wprost magazine.
In one, Foreign Minister Radoslaw Sikorski allegedly says that Poland’s alliance with the US is worthless.
Donald Tusk’s government has won a parliamentary vote of confidence sparked by a scandal over leaked tapes of Polish senior officials
In another, Central Bank head Marek Belka and Interior Minister Bartlomiej Sienkiewicz are apparently heard discussing how the bank could help the governing party win re-election in 2015; such action would be in violation of the bank’s independence.
All have said their words were taken out of context and they deny any wrongdoing.
Wprost said it obtained the recordings from a businessman.
In Wednesday’s vote, Donald Tusk’s centre-right two-party coalition received backing from 237 lawmakers, with 203 against in the 460-member parliament. The prime minister needed a simple majority of 231 for the vote of confidence to pass.
Donald Tusk had called for the vote before heading to the EU summit in Brussels later this week.
The secret recordings were made over several months at locations including high-end Warsaw restaurants.
In a speech to parliament earlier on Wednesday, Donald Tusk said he believed a criminal group was behind the recordings.
Polish prosecutors say they have charged two people with illegally recording conversations and were questioning two more.
Barack Obama has caused an outcry in Poland after referring to a Nazi death camp as “Polish”.
President Barack Obama made the remark at a ceremony in which he posthumously awarded Polish resistance fighter Jan Karski with the Presidential Medal of Freedom.
The White House says Barack Obama “misspoke” and regrets the comment but prominent Poles want an apology.
Poles suffered a brutal Nazi wartime occupation and reject any suggestion of responsibility for Nazi crimes.
Poles are particularly sensitive to comments linking their country to the Holocaust.
For years, they have objected to any description of Nazi German death camps as “Polish” because it can indicate involvement in the mass murder of millions of European Jews in camps built on their land.
Barack Obama has caused an outcry in Poland after referring to a Nazi death camp as "Polish"
Polish Prime Minister Donald Tusk stopped short of calling for an apology but said he wanted to see more than an expression of regret.
“I am convinced that today our American friends are capable of a stronger reaction… than just the correction itself and the regret which we heard from the White House spokesperson,” Donald Tusk said in a statement.
But Foreign Minister Radoslaw Sikorski was more forthright.
“The White House will apologize for the outrageous mistake,” he tweeted.
At the Medal of Freedom ceremony, Barack Obama spoke of Jan Karski’s efforts to draw attention to Nazi crimes in Poland.
Jan Karski had travelled first to London and then to the US to tell wartime President Franklin Roosevelt what he had witnessed.
“Before one trip across enemy lines, resistance fighters told him that Jews were being murdered on a massive scale, and smuggled him into the Warsaw Ghetto and a Polish death camp to see for himself,” Barack Obama said.
Jan Karski later became professor of history at Georgetown University and died in Washington aged 86 in 2000.
Almost six million Poles died in World War II. More than half were Jews, many of them killed in Nazi death camps including the infamous Auschwitz-Birkenau camp.
Some 1.1 million people were killed at Auschwitz, including 300,000 Polish Jews.
Polish diplomats and overseas organizations have campaigned to stop the use of the phrase “Polish death camps” as a shorthand description of Auschwitz or Treblinka.
“We should use this huge gaffe to make sure nobody, nowhere in the world, ever says that again,” Polish Nobel Peace Prize winner Lech Walesa said.