VALLETTA/MADRID (Reuters) - Malta said on Tuesday it would allow the Mediterranean rescue ship Aquarius, which has been barred for four days from several coastal states, to dock after five European Union countries agreed to take in the 141 migrants on board.

The boat, run by the Franco-German charity SOS Mediterranee and Doctors without Borders (MSF), had been at the center of the latest continent-wide tug-of-war over how to cope with the arrival of seaborne migrants.

The migrants rescued off the coast of Libya together with some others who arrived in Malta separately will be distributed among France, Germany, Luxembourg, Portugal and Spain, according to Spanish deputy prime minister Carmen Calvo, who said the final number of people involved came to 255.

She also said Italy would take some of the migrants in, but Italy’s far right interior minister and deputy prime minister Matteo Salvini said on Twitter that Rome would not take any of them.

“The NGO ship Aquarius will go to Malta and the migrants on board will be distributed between Spain, France, Luxembourg, Portugal and Germany. As promised, not in Italy. We’ve already done enough”, Salvini said on Twitter.

The row over the Aquarius illustrates again how politically fraught the issue remains despite the deal on migration that EU leaders agreed on at a summit in June.

The charities gave a cautious welcome to the deal, saying EU states now needed to agree on a more permanent mechanism that would avoid seeing rescue ships stranded at sea for days.

“Maybe European states have finally understood that this concerns our common border at the south of Europe, that this is a problem for the 28 member states, and that we can’t avoid responsibility and should work together,” Frederic Penard, director of operations at SOS Mediterranee, told a news conference.

The migrants on the Aquarius were rescued from boats off Libya. Malta had initially argued they should be taken to Libya, Tunisia or the Italian island of Lampedusa, all closer to the rescue points.

“The decision was made in a context of humanitarian emergency and highlights the importance of having a lasting and sustainable mechanism to avoid the repetition of crises,” French President Emmanuel Macron’s office said in a statement.

According to the Spain’s Calvo, Spain will take 60 migrants, France another 60, Germany 50, Portugal 30, Luxembourg five, and 50 will remain in Malta.

Protracted feuds between EU states over how to handle the influx of migrants have thrown the issue back onto the European agenda, despite the fact that overall Mediterranean arrivals have dropped sharply since peaking at around 1 million in 2015.

EU border agency Frontex said on Monday it had counted 73,500 “irregular border crossings” into the bloc so far this year via the sea and the Western Balkans route, more than 40 percent fewer than in the first seven months of 2017.

Slideshow ( 10 images )

Spain took in 629 mainly sub-Saharan Africans from the same rescue boat in June, and Spanish Prime Minister Pedro Sanchez said this had helped pave the way to Tuesday’s deal, which Malta called “a concrete example of European leadership and solidarity”.