Spain says it has accepted an offer from France to take in some of the 630 migrants rescued by the Aquarius ship off Libya and turned away by Italy.
The Spanish Deputy Prime Minister Carmen Calvo said the French government would work together with Spain to handle the arrival of the migrants.
They are scheduled to dock in Valencia on Sunday.
Madrid said that those migrants who expressed a wish to go to France would be allowed to do so.
The fate of the ship caused a diplomatic row between Italy and France, with French President Emmanuel Macron accusing Italy of “irresponsibility” for turning it away.
Italy, meanwhile, under its tough-talking new Prime Minister Giuseppe Conte, says it is unfair that countries on the frontline of the EU have had to carry most of the burden of handling the migrant influx.
On Friday, Mr Conte and Mr Macron agreed the current system must be reformed.
Separately, the Spanish coast guard said it had rescued 933 migrants and found four bodies in the Mediterranean on Friday and Saturday, reported Reuters news agency.
Spain’s Prime Minister Pedro Sanchez has adopted a migrant-friendly stance since taking up his post two weeks ago.
The migrants aboard the Aquarius spent 20 hours in overcrowded rubber dinghies before being rescued by the Aquarius off the Libyan coast. They have since spent a week aboard the rescue ship in rough seas – with many aboard suffering seasickness.
The migrants will be met by a team of 2,300 people, primarily health workers, when the Aquarius docks on Sunday, Efe news agency reports.
They will then be given a choice as to whether to go on to France if it is established that they have a claim to asylum, Efe quoted the French foreign minister as saying.
Migration reform is likely to be a key topic at a meeting of EU leaders later this month, as many countries continue to grapple with the political fallout caused by an influx of migrants in recent years.
Italy’s populist coalition – and in particular its interior minister, the right-wing League party leader Matteo Salvini – has taken a hard-line approach to immigration, resulting in the diplomatic row over the fate of the Aquarius.