LESBOS - UN chief Ban Ki-Moon said Saturday that the "detention" of migrants who have arrived in Greece since March should cease immediately, as he visited the frontline of the migration crisis engulfing Europe.

He made the comments after visiting two camps on the Greek island of Lesbos, where some 3,400 migrants are being held while officials assess whether they can legitimately claim asylum. "Detention is not the answer, it should end immediately," said Ban, who held talks with Greek Prime Minister Alexis Tsipras in Athens earlier in the day.

"I recognise the difficulties but the world has the wealth, the capacity and the duty to meet these challenges," he said on Lesbos, the entry point for hundreds of thousands of migrants arriving in the EU last year. "These people have been through the worst," Ban added. "The people of Lesbos are showing the world the best -- you have opened your homes, hearts and wallets to support people in need."

Under a controversial deal between the European Union and Turkey that came into force in March, failed asylum seekers face being sent back from the Greek islands to Turkey. More than 45,000 migrants are currently trapped on Greek territory, following not just the EU-Turkey deal but also a string of border closures in Balkan countries to the north.

Most of the migrants are now in state-run camps that aid groups including the UN's refugee agency have labelled poorly-equipped and inappropriate for a long stay. Ban praised Greeks for showing "remarkable solidarity ... as Greece faces tremendous challenges of so many desperate people fleeing war and persecution".

Greece's Aegean holiday islands have seen more than a million refugees and migrants arrive over the last year-and-a-half -- many of them Syrian refugees -- seeking new lives elsewhere in the EU. Lesbos alone accounted for around 500,000 arrivals in 2015, according to UN figures, as Europe battles its worst migration crisis since World War II. The EU-Turkey deal has drastically reduced the flow, but rights groups say this has come at the cost of human rights violations.

On Friday, medical aid group Doctors Without Borders said it would no longer accept funding from the EU in protest at its "shameful" migration policies, including the Turkey deal. Since it came into force in March, more than 460 people have been sent back to Turkey, where critics say they face discrimination and possible danger.