By Humeyra Pamuk and Gabriela Baczynska

BRUSSELS (Reuters) - The European Union sealed a controversial deal with Turkey on Friday 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," 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," 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 April 4, 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, criticizing Ankara's track-record on human rights.

Story continues

"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."

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.

Dutch Prime Minister Mark Rutte sought to reverse the narrative, saying the idea was to discourage illegal and perilous voyages across the Aegean and open legal paths to Europe instead.

"There is nothing humanitarian in letting people, families, children, step on boats, being tempted by cynical smugglers, and risk their lives," he said.

DOABLE?

The EU would also accelerate disbursement of 3 billion euros already pledged in support for refugees in Turkey and provide a further 3 billion 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, European Council President Donald Tusk, said the deal was not a silver bullet.

"Reality is more complex," 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," Davutoglu said. "Today we realized that Turkey and EU have the same destiny, the same challenges and the same future."

Turkey's four-decade-old dispute with Cyprus had been a key stumbling block. Cypriot President Nicos Anastasiades insisted there could be no opening of new "chapters" in Turkey's EU talks until Ankara de facto recognizes the Cypriot state.

But the issue was sidestepped as EU leaders agreed to open a negotiating chapter that was not one of the five blocked by Nicosia. Anastasiades said he was "fully satisfied" after the sides agreed to swiftly open only chapter 33 on budget policy.

Ankara's central objective -- visa-free travel for Turks to Europe by June -- would still depend on Turkey meeting 72 long-standing EU criteria.

Facing a backlash from anti-immigration populists across Europe, the EU is desperate to stem the influx but faced legal obstacles to blanket returns of migrants to Turkey.

EU partners would provide additional manpower and resources to help Athens cope with the new challenge and with a backlog of 43,000 migrants already bottled up on its territory.

While the talks were in progress, Turkish President Tayyip Erdogan accused the EU of hypocrisy over migrants, human rights and terrorism, as supporters of the militant Kurdistan Workers Party (PKK) set up protest tents near the summit venue.

Erdogan said Europe was "dancing in a minefield" by directly or indirectly supporting terrorist groups.

"At a time when Turkey is hosting three million, those who are unable to find space for a handful of refugees, who in the middle of Europe keep these innocents in shameful conditions, must first look at themselves," he said in a televised speech.

(Reporting by Renee Maltezou, Robin Emmott, Paul Taylor, Andreas Rinke, Gabriela Baczynska, Julia Fioretti, Jan Strupczewski, Humeyra Pamuk, Alastair Macdonald, Elizabeth Pineau, Tom Koerkemeir in Brussels and Ayla Jean Yackley in Istanbul, Writing by Paul Taylor and Gabriela Baczynska, Editing by Alastair Macdonald and Catherine Evans)