ROME/MADRID (Reuters) - Italian Prime Minister Giuseppe Conte said on Thursday that six EU countries had agreed to take in some 150 migrants from a rescue ship that Italy had blocked from docking, resolving the latest standoff over immigration to Europe across the Mediterranean.

The migrants have been stranded on the Spanish charity ship Open Arms since it picked them up off Libya in early August, and Rome’s far-right interior minister, Matteo Salvini, refused to allow them to disembark.

The migrants will be shared out among France, Germany, Romania, Portugal, Spain and Luxembourg, Conte said in an open letter to Salvini in which he accused the minister of disloyalty and being “obsessed” with closing Italy’s ports to migrants.

The Open Arms, operated by a Spanish charity of the same name, was in Italian territorial waters on Thursday, a day after a Rome administrative court gave it leave to enter them, countermanding Salvini’s ban..

Before Conte’s announcement, Spain said it was working with other EU states and the European Commission to find a “common... and orderly solution”, and was willing to “participate in a balanced distribution of migrants on board the ship.”

French and German officials confirmed talks were under way to resolve this latest in a series of flashpoints over immigration involving Italy, and one that has fueled infighting in a coalition government in Rome that is close to collapse.

Salvini, who heads the League party that forms part of the coalition, issued an emergency order to prevent Open Arms arriving at the Italian island of Lampedusa. But the defence minister, who is from the League’s partner party 5-Star, refused to countersign it.

Slideshow ( 8 images )

Openly challenging the League leader, who has so far dictated Italy’s immigration policy, Elisabetta Trenta said defying the court was illegal and that “politics must not lose its humanity.”

The League and the anti-establishment 5-Star Movement were already in open conflict after Salvini said last week the alliance had become unworkable and called for elections.

The League has tabled a motion of no-confidence in the government, and the premier Conte, a former academic who is not from either ruling party, vented his anger in his open letter to Salvini.

He accused the far-right leader of “disloyal collaboration” by misrepresenting Conte’s own position, and of exploiting the issue of immigration for electoral gain rather than seeking necessary solutions with Italy’s partners.

Hollywood star Richard Gere visited the Open Arms last week and urged the Italian government to stop “demonising people” and allow the boat to disembark.

The charity’s spokeswoman said the ship was anchored five miles (eight km) off Lampedusa.

Spanish public broadcaster TVE, who are present on the Open Arms, interviewed a migrant, who said they would only really rejoice once they will have reached the shore. “We need to touch ground, life is over there, here it’s death,” said the woman, whom TVE did not name.

“We’re waiting,” the Open Arms spokeswoman said.