BRUSSELS/MILAN (Reuters) - Six European Union countries have agreed to take in the 356 migrants stranded at sea for two weeks aboard the Ocean Viking rescue vessel, ending the latest standoff in the bloc over migration across the Mediterranean.

The migrants aboard the ship, which is run by French charities, will be taken to Malta before being received by France, Germany, Romania, Luxembourg, Portugal and Ireland, the EU migration commissioner and Maltese prime minister said.

“Welcome that a solution for the persons aboard Ocean Viking has been found and that all will be relocated,” EU Commissioner Dimitris Avramopoulos said.

The plight of the Ocean Viking, run by Médecins Sans Frontières (MSF) and another French charity, SOS Méditerranée, has exposed Europe’s failure to come up with a coherent policy to deal with migration from Africa through Libya.

EU states have been at loggerheads over how to handle refugees and migrants reaching its shores since a 2015 spike in Mediterranean arrivals of people fleeing conflicts and poverty in the Middle East and Africa.

With the EU’s eastern, ex-communist states refusing to host any of the new arrivals, the bloc has increasingly turned to tightening its borders and asylum laws, turning people away or paying countries like Turkey to stop them reaching Europe.

Italy had long complained that it was not getting enough EU support before its far-right interior minister, Matteo Salvini, shut the country’s ports to rescue ships run by aid groups.

Slideshow ( 5 images )

Since then, such vessels have repeatedly been left stuck at sea for days or weeks as EU states spar over what to do with the people aboard.

On Tuesday, around a hundred migrants stranded for weeks on board another rescue ship, the Open Arms, disembarked on the Italian island of Lampedusa - but only after Spain, France, Germany, Luxembourg and Portugal agreed to take them in.

Irish Foreign Minister Simon Coveney on Friday criticized the lack of coordinated EU response: “Ad hoc arrangements on a case by case basis is not sustainable or humane. EU is better than this!,” he said on Twitter.

Ireland decided to accept up to 100 asylum-seekers during the remainder of this year.

REPEATED STANDOFFS

Providing sanctuary to migrants and refugees is currently left to the goodwill of member states who come forward as the emergencies unfold.

Slideshow ( 5 images )

“European governments need to bring to a definitive end prolonged standoffs and petty case-by-case negotiations to come up immediately with a predetermined disembarking mechanism, MSF said.

Maltese Prime Minister Joseph Muscat said on Twitter the migrants on Ocean Viking would be picked up in international waters and then transferred onshore by Maltese military boats.

France said it would take in 150 of the migrants, after initially committing to sheltering only 40. Portugal said late on Thursday it was ready to take up to 35 migrants.

The ship, which had been stranded in international waters between Malta and the southern Italian island of Linosa, had been denied entry by Malta while requests to Italy had gone unanswered, the charities previously said.

Salvini has called the private rescue ships “taxis” for people-smugglers, saying Italy should not be “Europe’s refugee camp”.

The Ocean Viking ship was carrying mostly Africans from Sudan, plucked from the sea in four separate missions. They include more than 100 minors, around 90 of them unaccompanied, and three children are under the age of five, MSF said.