The European Union sealed a controversial deal with Turkey today intended to halt illegal migration flows to Europe in return for financial and political rewards for Ankara.

The accord aims to close the main route by which a million migrants and refugees poured across the Aegean Sea to Greece in the last year before marching north to Germany and Sweden.

But deep doubts remain about whether it is legal or workable, a point acknowledged even by German Chancellor Angela Merkel who has been the key driving force behind the agreement.

"I have no illusions that what we agreed today will be accompanied by further setbacks. There are big legal challenges that we must now overcome," Ms Merkel said after the 28 EU leaders concluded the deal with Turkish Prime Minister Ahmet Davutoglu.

"But I think we've reached an agreement that has an irreversible momentum," Ms Merkel said, adding it showed that the EU was still capable of taking difficult decisions and managing complex crises.

Under the pact, Ankara would take back all migrants and refugees, including Syrians, who cross to Greece illegally across the sea.

In return, the EU would take in thousands of Syrian refugees directly from Turkey and reward it with more money, early visa-free travel and faster progress in EU membership talks.

Migrants who arrive in Greece from Sunday will be subject to being sent back once they have been registered and their individual asylum claim processed. The returns are to begin on 4 April, as would resettlement of Syrian refugees in Europe.

While many in Brussels hailed the agreement as a game-changer, Amnesty International decried it as a "historic blow to human rights", saying Europe was turning its back on refugees.

"Guarantees to scrupulously respect international law are incompatible with the touted return to Turkey of all irregular migrants," the rights advocacy group said, criticising Ankara's track record on human rights.

"Turkey is not a safe country for refugees and migrants, and any return process predicated on it being so will be flawed, illegal and immoral," added the rights advocacy group.

Turkey's human rights record has drawn mounting criticism amid a crackdown on Kurdish separatists, arrests of critical journalists and the seizure of its best-selling newspaper.

Acting Taoiseach Enda Kenny said today's agreement requires Turkey to re-admit "irregular migrants" from Greece and to protect them in accordance with international standards.

He said it also commits to tackle people smugglers and help prevent new routes to the EU from opening up.

Speaking in Brussels, Mr Kenny said European Council President Donald Tusk and his team had worked very hard so that all the concerns and anxieties expressed were addressed and that the proposed deal was compatible with EU and international law.

The EU would also accelerate disbursement of €3bn already pledged in support for refugees in Turkey and provide a further €3bn by 2018. It would help Greece set up a task-force of some 4,000 staff, including judges, interpreters, border guards and others to manage each case individually.

"All new irregular migrants crossing from Turkey into Greek islands as from 20 March 2016 will be returned to Turkey. This will take place in full accordance with EU and international law, excluding any kind of collective expulsion," the deal said.

European Commission President Jean-Claude Juncker said it would be a Herculean task for Greece to handle the returns and the chairman of the EU leaders' summits, Mr Tusk said the deal was not a silver bullet.

"Reality is more complex," Mr Tusk said, noting a broader EU strategy to control migration that included keeping the land route from Greece to Germany closed to irregular migrants.

Just as the deal was clinched, Turkey said it had intercepted hundreds of migrants trying to reach the Greek island of Lesbos.

"It's a historic day today because we reached a very important agreement between Turkey and the EU," Mr Davutoglu said. "Today we realised that Turkey and EU have the same destiny, the same challenges and the same future."

Meanwhile, Amnesty International Ireland has said it is not credible that Turkey will be able to put in place logistics to deal with measures hammered out at an EU summit to deal with the migrants crisis.

Speaking on RTÉ's Morning Ireland, the organisation's chief executive Colm O'Gorman said even if the measures are implemented, Turkey cannot be determined to be a safe country for migrants.

He described the deal as flawed and said if the route through Turkey closes, migrants will find other routes into Europe.

"It’s simply not credible or realistic to imagine that they'll now be able to put in place processes that will comply with the rules of international law and indeed with European Law, that will allow refugees who reach Greece real and meaningful individual assessments of their right to protection, of their right to asylum or refugee status in Greece before a decision is made to deport them for instance to Turkey."