Spain's new prime minister on Monday gave orders for authorities to receive a rescue vessel carrying 629 migrants which has remained at sea in the Mediterranean after both the Italian and Maltese governments, the two nearest European territories, refused it permission to disembark.

The decision from Socialist Party leader Pedro Sánchez was in stark contrast to the stance of Italy's interior minister, Matteo Salvini, leader of an anti-immigration and far-right outfit in the coalition government who on Sunday said his country would start saying no to what he termed human trafficking and illegal immigration, and thus refused to assist the Aquarius ship.

"It is our obligation to avoid a humanitarian catastrophe and offer a safe port to these people and fulfill our obligations to uphold international human rights," said the Spanish PM, whose new-female majority cabinet only took office on Friday, a week after they lodged a successful motion of no-confidence against Mariano Rajoy's conservative government.

The vessel, which belongs to French NGO SOS Méditerranée, was carrying at least 123 unaccompanied minors, 11 small children and seven pregnant women who were pulled from flimsy boats trying to cross the Mediterranean on Saturday.

It is expected to dock in Valencia in the southeast of Spain.

Italy's prime minister, Giuseppe Conte, and his Maltese counterpart Joseph Muscat thanked Sánchez for his actions, but the former, an outsider brought in to represent the eurosceptic populist and right-wing coalition, also used the occasion to take a swipe at the European Union.

"We were missing a gesture of solidarity from the European Union on this emergency. I must thank the Spanish authorities for accepting our request," Conte told reporters in the central Italian city of Accumoli.

Neither Italy nor Malta said they were willing to take in the boat, despite doctors on board warning that there was only enough food and water to survive at sea for one more day.

Sánchez's decision to allow the boat entrance to Valencia could be seen by some as a gesture to set the tone of his new center-left executive.