Italy and Malta had both refused to let the Gibraltar-flagged Aquarius ship, whose 629 passengers included 11 children and seven pregnant women rescued off the coast of Libya at the weekend, to dock, prompting the European Union and the UN refugee agency to call for a swift end to the standoff.

The ship had sailed north toward Italy but Matteo Salvini, the head of the far-right League party who became interior minister this month vowing to curb an influx of migrants from Africa, blocked it and said it should go to Malta instead.

Malta refused, saying it had nothing to do with the rescue mission, which was overseen by the Italian coastguard.

The tiny island nation with fewer than a half a million inhabitants says it already accepts more refugees per capita than Italy, which has taken in more than 600,000 boat migrants since 2014.

“Victory!” tweeted Matteo Salvini, deputy prime minister and leader of the far-right League, after the offer from Spanish Prime Minister Pedro Sanchez to admit the ship to the port of Valencia.

“To politely raise one’s voice pays off; it’s something Italy hasn’t done for many years,” Salvini, who in his role as interior minister is leading the crackdown on immigration, said at a news conference.

Prime Minister Giuseppe Conte also welcomed Spain’s move, saying on Facebook that Italy was “no longer alone”, and adding that the goal was now to make the European Union rules on asylum “fairer for everybody”.