Spain’s prime minister has said the country will take in a rescue ship stranded in the Mediterranean, to help avoid a humanitarian catastrophe.

Pedro Sánchez said he would give “safe harbour” to the Aquarius and the 629 people on board, after Italy and Malta both refused to let the ship dock reports BBC.

The UN refugee agency and the EU had both called for a swift end to the stand-off between the two countries.

Mr Sánchez has said the ship will dock in Valencia.

The migrants aboard the Aquarius were picked up in six different rescue operations off Libya’s coast, according to the German charity SOS Méditerranée.

“It is our duty to help avoid a humanitarian catastrophe and offer a safe port to these people, to comply with our human rights obligations,” Mr Sanchez’s office said.

Who is on board the ship?

Those saved include 123 unaccompanied minors, 11 younger children and seven pregnant women, SOS Méditerranée said.

The minors are aged between 13 and 17 and come from Eritrea, Ghana, Nigeria and Sudan, according to a journalist on the ship, Anelise Borges.

“Most of them are sleeping outside. They are obviously exhausted, they have been exposed to the elements, they have been at sea for 20 to 30 hours prior to their rescue,” she told the BBC.

“They are fragile and we have yet to learn what’s going to happen to them,” she added.

Why didn’t Italy or Malta take the ship?

Italy’s new Interior Minister Matteo Salvini refused to let it in, saying: “Saving lives is a duty, turning Italy into a huge refugee camp is not.”

Mr Salvini, leader of the right-wing League party, promised during Italy’s recent general election to take a tough stance against migration.

  • Reality Check: Claims about migrants arriving in Italy
  • Desperate migrants rescued from the sea
  • UN sanctions for people traffickers in Libya

He said Malta should accept the Aquarius, but it refused, arguing that it falls under Italy’s jurisdiction.

Italy is the main entry point for migrants crossing from North Africa to Europe.

Mr Salvini has previously said he is considering action against organisations that rescue migrants at sea. He has accused them of being in cahoots with people-smugglers.

On Sunday, he said that Italy was saying “no to human trafficking, no to the business of illegal immigration”.

“Malta takes in nobody,” he added. “France pushes people back at the border, Spain defends its frontier with weapons.”

SOS Méditerranée said late on Sunday that the Aquarius had been instructed by the Italian Maritime Rescue Co-ordination Centre to stand by in its current position, 35 nautical miles (65km) from Italy and 27 nautical miles from Malta.

Despite Mr Salvini’s stance, the mayors of Taranto and Naples had both offered to welcome the migrants, with Taranto’s Rinaldo Melucci saying the Italian port city was “ready to embrace every life in danger”.

Naples mayor Luigi de Magistris tweeted 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”.

What about Malta?

A spokesman for the Maltese government told AFP news agency Malta was “neither the co-ordinating nor the competent authority” in the rescue operation.

Prime Minister Joseph Muscat insisted that Malta would not allow Aquarius to dock at its ports and said Italy’s instructions to the boat were dangerous.

  • Is Europe seeing a nationalist surge?
  • Populists take power in Italy: What comes next?
  • Italy country profile

“They manifestly go against international rules, and risk creating a dangerous situation for all those involved,” he said in a tweet.