Spain will take in 60 of the 141 migrants on board the Aquarius rescue ship as part of an agreement with other European nations, Prime Minister Pedro Sanchez said Tuesday.
"Spain has coordinated a pioneering agreement with six countries to distribute the reception of the people of the Aquarius.. Spain will receive 60 people," he wrote on Twitter.
At the same time, his Maltese counterpart Joseph Muscat said Valetta would allow the boat to dock and that those on board would be sent to France, Germany, Luxembourg, Portugal and Spain in a posting on Twitter.
Malta had at the end of June agreed to take in another rescue boat called the Lifeline which was carrying 234 people after a similar deal was struck with EU states to take the migrants in.
That incident came just two weeks after another crisis involving the Aquarius which had been had been turned away by Italy and Malta with 630 people on board but was eventually offered safe haven by Spain’s new Socialist government.
But this time, Madrid was reluctant to repeat the offer amid strong criticism over its welcoming stance from the conservative opposition and the regional Socialist government in Andalusia less than a year from regional and European Union elections.
For migrants, the southern Andalusia region is the main gateway into Spain, and the region has struggled to cope with an influx in migrant arrivals.
Speaking to AFP on Monday, a Spanish government source said Madrid did not intend to repeat the gesture by allowing the Aquarius to dock in the eastern port of Valencia, saying it was "not the safest port" for the ship.
While the overall number of migrants reaching Europe by sea is down from the peak in 2015, Spain has seen a steady increase in sea arrivals that began more than a year ago and has surged in recent months.
The country has overtaken Italy as a destination for migrants arriving by sea after a crackdown by Libyan authorities made it more difficult for migrants to reach Italian shores.
Over 25,000 people have arrived by sea in Spain so far this year, nearly three times more than the same period last year, International Organization for Migration figures show.
Since taking in the Aquarius in June, Spain has opened its ports three more times to NGO ships carrying migrants rescued off Libya.