PARIS/LISBON (Reuters) - France, Portugal, Spain and Germany struck a deal on Tuesday to take in migrants from the Mediterranean rescue ship Aquarius sailing off the coast of Malta, the French government said, after Italy refused to let the vessel dock.

The agreement marks the second such co-operation between European countries since Italy’s new anti-establishment coalition started turning away from Italian ports ships carrying migrants rescued in the Mediterranean earlier this year.

Portugal said it had agreed to take 10 of the 58 migrants on board as part of a “response of solidarity to the flow of migrants seeking to reach Europe across the Mediterranean”.

Malta said migrants would be transferred to a patrol boat in international waters and taken to the island, which will then send them to four other European Union states.

It was not immediately clear how many migrants Spain and Germany had agreed to take in, though a French government source said France would take 18.

The French prime minister’s office said the Aquarius, whose registration was revoked by Panama earlier this week, would head to Marseille once its passengers had disembarked.

“Malta and France again step up to solve (the) migrant impasse,” Maltese Prime Minister Joseph Muscat said on Twitter, adding that he, French President Emmanuel Macron and other leaders wanted to show a multilateral approach was possible.

On Sunday, Italian Interior Minister Matteo Salvini of the far-right League Party said the Aquarius had hindered the work of the Libyan coast guard and Italy’s ports would remain shut.

A public backlash over the arrival of hundreds of thousands of migrants in the past five years has fuelled a swing towards far-right parties in many countries in Europe and helped bring Italy’s anti-establishment ruling coalition to power this year.

France had initially refused to let the Aquarius dock in Marseille, as requested by the charities operating the ship, arguing that under European rules, the ship was supposed to dock at the nearest port, in this case Malta.

In August, France and Malta struck a deal to let the Aquarius dock in Valletta harbour after France, Germany, Luxembourg, Portugal and Spain agreed to take in the migrants, ending a five-day tug-of-war among EU countries.

Aquarius 2 is the one remaining charity rescue vessel still operating in the central Mediterranean, picking up migrants who are in most cases trying to get to Europe from Libya, often in overcrowded, unseaworthy boats.

Italy became the main route into Europe for hundreds of thousands of asylum seekers arriving by sea since the other main route from Turkey to Greece was largely shut in 2016.

Slideshow ( 4 images )

On Monday, Panama authorities revoked the Aquarius’s registration, meaning that once it docks it will be ‘de-flagged’ and will not have the right to sail unless a new registration is found.