Madrid said Saturday it has accepted an offer from France to take in some of the 630 migrants from the Aquarius rescue ship following a turbulent week that saw Italy spurning people plucked from the Mediterranean.
The boat, which is due to arrive in Spain on Sunday morning, has been the heart of a major migration row between European Union member states.
"The French government will work together with the Spanish government to handle the arrival of the migrants", Spain's deputy prime minister Carmen Calvo said.
"France will accept migrants who express the wish to go there" once they have been processed in Valencia, a statement said.
Prime Minister Pedro Sanchez meanwhile thanked French President Emmanuel Macron for his gesture, saying it was "exactly the kind of cooperation Europe needs" at this hour.
In Valencia, preparations were underway to welcome the worn-out travellers after their long ordeal. A huge banner was put up at the port saying "Welcome home" in various languages including Catalan, the local language, and Arab.
Chartered by a French aid group, the vessel rescued 629 migrants including many children and pregnant women off Libya's cost last weekend.
Doctors Without Borders (MSF), who along with French charity SOS Mediterranee are treating migrants on board Aquarius, said two passengers drowned last weekend when the ship first encountered difficulties off Libya.
The passengers come from 26 countries, mainly from Africa but also Afghanistan, Bangladesh and Pakistan, according to MSF.
Among them are 450 adult men and 80 women -- including at least seven pregnant women -- as well as 11 under-13s and 93 adolescents, according to figures released by authorities in Valencia.
A team of 2,320 people has been mobilised to meet them, including 1,000 Red Cross volunteers and 470 translators. More than 600 journalists have been accredited to cover the arrivals.
Authorities in Valencia have meanwhile received more than 2,000 calls and messages from individuals offering help.
Italy's new populist government and Malta refused to let Aquarius dock in their ports, accusing each other of failing to meet their humanitarian and EU commitments.
Spain eventually stepped in and agreed to receive the refugees as a "political gesture" to "oblige Europe to forge a common policy to a common problem," Foreign Minister Josep Borrell said.
France -- who had angered Rome by branding it irresponsible over the vessel rejection -- offered Thursday to welcome Aquarius migrants who "meet the criteria for asylum".
The ship is making the 1,500-kilometre (930-mile) voyage to Spain accompanied by Italian coast guard vessels, which have taken on board some of the migrants.
High waves and winds forced the convoy to take a detour on the way, but the first migrants are expected to land in Valencia between 6am (0800 GMT) and 12pm (1400 GMT) on Sunday.
The plight of the Aquarius has again highlighted the failure of EU member states to work together to deal with the influx of migrant arrivals since 2015.
After Rome's decision to ban the Aquarius, French President Emmanuel Macron and Italian Prime Minister Giuseppe Conte met on Friday and agreed that the EU should set up asylum processing centres in Africa to prevent "voyages of death."
They also demanded "profound" changes to the EU's asylum rules which put the migrant burden on their port of entry to Europe -- mainly Italy and Greece.
Italy's far-right Interior Minister Matteo Salvini warned Saturday that other NGO operated rescue ships would also be banned from docking.
"While the Aquarius is sailing towards Spain, two other Dutch NGO operated vessels (Lifeline and Seefuchs) have arrived off the Libyan coast, to wait for their human cargos once the people smugglers abandon them," Salvini said in a Facebook post.
"These people should know that Italy no longer wants to be any part of this business of clandestine immigration and they will have to look for other ports to go to," he said.
"As minister and as a father, I take this action for the benefit of all," he added.