Earlier in the day UNHCR, the United Nations refugee agency, had previously appealed to the governments of Malta and Italy to allow the immediate disembarkation of the hundreds of people now aboard the rescue ship Aquarius, which is now stranded in worldwide waters.
Spain's new Socialist prime minister, Pedro Sanchez, ordered authorities in Valencia to open the port, saying "it's our duty to avoid a humanitarian catastrophe and offer a secure port for these people".
The UNHCR says migrants aboard the rescue ship Aquarius are in distress, running out of provision and urgently in need of help.
"It is our obligation to help avoid a humanitarian catastrophe and offer "a safe harbor" to these people, thus complying with obligations of worldwide law", he said in a statement. It ends what was becoming an increasingly hard and untenable situation for the crew of the Aquarius and the more than 600 rescued people who were aboard.
The EU and the bloc's biggest member state Germany made similar pleas.
Earlier in the day, the Maltese government also refused to accept migrants from the Acquarius.
"From now on, Italy isn't alone, and we hope other European leaders follow" Spain's example, said Di Maio, who along with the League is seeking to renegotiate the EU regulations that determine which EU country is responsible for processing asylum claims.
A little more than a week ago, Italy's new interior minister, Matteo Salvini, told a crowd that "Italy and Sicily can not be Europe's refugee camp" and "the good times for illegals are over", Deutsche Welle reports.
"Italy has stopped bowing its head and obeying, this time THERE ARE THOSE WHO SAY NO", he tweeted Monday.
The Maltese government insisted it was "acting in full conformity with its global obligations".
SOS Mediterranee spokesperson Mathilde Auvillain said the Aquarius had received orders to head north after a series of sea rescues and was now awaiting "definitive instructions".
He tweeted:.Chiudiamoiporti. "We're closing the ports".
The mayors of Palermo, Taranto, Messina and Reggio Calabria, have also said they would be ready to welcome the vessel. It added that the Aquarius "is still waiting for definitive instructions regarding the port of safety". Although there were no immediate emergencies on board, the spokesman said, there were many who needed medical care for chemical burns, hypothermia and dehydration.
Will Malta accept the ship?
Where were the migrants rescued from?
"The people we saved yesterday were in a hard condition, at least 50 were at risk of drowning".
"We would need a resupply at sea which is not so easy to organize so we urge Italy to find a solution very soon close to our position", he told The Associated Press in Paris.
The Aquarius, a humanitarian ship run by the NGO SOS Mediterranean and Doctors Without Borders (MSF), said it saved 946 people, including 200 unaccompanied minors rescued after being found drifting on nine wooden and rubber boats.
But that does not mean a country can simply hold up a stop sign and wash its hands of the situation when a vessel packed with vulnerable migrants approaches its shores.
Italy has been the de facto destination for rescue boats since the migrant crisis began five years ago.
After urging a quick resolution of the impasse earlier in the day, the United Nations refugee agency, through spokesman Charlie Yaxley, said Sanchez's offer "is a welcome development and a great display of solidarity from Spain with refugees".