Spain offered on Monday to take in a ship stranded in the Mediterranean with 629 migrants aboard after Italy and Malta refused to let the vessel dock in their ports.
The migrants, including pregnant women and scores of children, were saved by the French charity SOS Mediterranee on Saturday.
They were taken on board its ship Aquarius, which is now between Malta and Sicily.
But Malta and Italy - whose new populist government has vowed a tough new stance on immigration - have both refused to take the migrants in, triggering concern in the international community about their plight.
Spain's new Socialist Prime Minister Pedro Sanchez agreed to allow the ship to dock in its eastern port of Valencia.
"The prime minister has given instructions for Spain to honour international commitments on humanitarian crises and announced that the country will receive the ship Aquarius," his office said in a statement.
"It is our obligation to help to avoid a humanitarian catastrophe and to offer a safe port to these people."
'Swift resolution'
The UN had called on Malta and Italy to immediately allow the boat to dock, describing the situation as "an urgent humanitarian imperative."
It suggested that the hundreds on board "are running out of provisions."
The EU and the bloc's biggest member state Germany made similar pleas.
"The priority of both the Italian and Maltese authorities should be ensuring these people receive the care they need," European Commission spokesman Margaritis Schinas told reporters, calling for a "swift resolution."
Italy's refusal to take in the migrants is the first sign of the new government's hardened stance on immigration.
Its far-right Interior Minister Matteo Salvini showed no sign of backing down on Monday.
"Saving lives is a duty, turning Italy into a huge refugee camp is not. Italy is done bending over backwards and obeying, this time THERE IS SOMEONE WHO SAYS NO," he wrote on Twitter followed by the hashtag #closethedoors.
The Maltese government insisted it was "acting in full conformity with its international obligations."
SOS Mediterranee tweeted late Sunday that the Aquarius had received instructions from the Italian Maritime Rescue Coordination Centre to stand by in its current position 35 nautical miles from Italy and 27 nautical miles from Malta.
'A land of refuge'
Under EU rules migrants must apply for asylum in the European country where they first arrive.
That has put pressure on Italy and Greece, the entry points for hundreds of thousands of people fleeing war and poverty in the Middle East, Africa and Asia since 2015.
Some in Italy have offered to take in migrants. The mayor of Taranto, Rinaldo Melucci said the southern port city was "ready to embrace every life in danger."
"Our land has always been one of refuge, I don't know how you can send away 629 human lives."
Naples mayor Luigi de Magistris said on Twitter that "if a minister without a heart leaves pregnant women, children, old people, human beings to die, the port of Naples is ready to welcome them".
EU leaders in December had set an end-June deadline for an overhaul of rules to create a permanent mechanism to deal with migrants in the event of a new emergency.
The summer of 2016 saw a surge in mass drownings in the Mediterranean, at the peak of Europe's worst migration crisis since World War II.


