Six European Union member states on Friday agreed to relocate the 356 migrants stranded on board the Ocean Viking rescue ship, ending a 14-day standoff.
The men, women and children — the youngest of whom is just a year old — will be taken to France, Germany, Ireland, Luxembourg, Portugal and Romania.
They will disembark the ship in Malta but won't remain on the Mediterranean island.
Christophe Castaner, France's Interior Minister, said the country would host 150 of them. It is unclear how many migrants the other countries will welcome.
The EU Commissioner for Migration, Home Affairs and Citizenship, Dimitris Avramapoulos, welcomed the solution and praised the member states who have pledged to host some of the migrants.
"These commitments must now be honoured swiftly," he added.
The ship, operated by SOS Méditerranée and Doctors Without Borders (MSF), rescued the 356 migrants in four separate rescue operations spread across four days starting on August 9.
MSF said in a statement that they attempted to contact the Libyan Rescue Coordination Centre but only received a response "well after the rescue — offering us to go to Libya, contrary to international law".
They then approached Maltese and Italian authorities to be granted access to a port to disembark but, as has become the norm, were rebuffed while EU countries negotiated a solution.
"While a coalition of countries has stepped up to give a humane response, European governments must stop these prolonged delays and ad hoc petty negotiations, and set up as a matter of urgency a disembarkation mechanism for people rescued at sea," MSF said.
Italy's far-right Interior Minister, Matteo Salvini, who plunged the country in a political crisis earlier this month when he decided to pull the plug on the struggling coalition with the populist Five Star Movement, celebrated on Twitter that the country will not host any of the 356 migrants.
"As promised, we have not given any permission to disembark in Italy for the 356 immigrants onboard the Ocean Viking. The security of Italians come first," he wrote.
Under his impulsion, the country criminalised access to its territorial waters for charity rescue ships.