VALLETTA, Malta (AP) — Malta on Tuesday agreed to let a private rescue ship dock on the island, with the 141 migrants it is carrying to be distributed among five fellow European Union nations in what was described as a “responsibility-sharing exercise.”

The migrants were plucked to safety by the aid boat Aquarius in two separate operations in the Mediterranean Sea off Libya on Friday. The boat was reported to be about 50 kilometers (35 miles) from Malta on Tuesday afternoon when the deal was announced.

“Malta will be making a concession allowing the vessel to enter its ports, despite having no legal obligation to do so,” the Maltese government said in a statement.

It said that Malta will serve as a logistical base and that all the migrants aboard will be distributed among France, Germany, Luxembourg, Portugal and Spain.

Previously this summer Malta had allowed another private aid group’s rescue vessel to dock, also on condition other nations take the migrants, although in that case Malta also agreed to take some.

Malta also noted that on Monday it had rescued 114 persons at sea, with 60 of them destined to go to other EU nations as part of cooperation in the bloc.

Aquarius had been waiting for safe harbor after appealing to Italy and Malta. Italy’s new populist government is refusing to allow any private rescue ships to dock, saying the country has done more than its share by allowing some 600,000 rescued migrants to disembark in previous years.

Malta said the dilemma over the fate of the migrants saved by Aquarius was resolved following French-Maltese discussions, and the agreement “with the support of the European Commission” to participate in a “responsibility-sharing exercise.”

Italy’s ruling coalition, which includes an anti-migrant party, has been lobbying for just such cooperation since it took power in June.

French President Emmanuel Macron tweeted, thanking Malta “for its humanitarian gesture” and saying France offers its full solidarity. “There’s no alternative to cooperation,” Macron said.

Portugal, which will take 30 of those aboard Aquarius, was the first country to say it could take in some of the migrants, after officials in Mediterranean areas of France made impassioned pleas to their government to allow the boat to dock there. Spain has agreed to take 60.

Operating Aquarius are two French aid groups, SOS Mediterranee and Doctors Without Borders, who said that many aboard are weak and malnourished. Many rescued migrants say they receive scanty rations while detained, often for months, in Libya, awaiting opportunity to depart aboard human traffickers’ unseaworthy boats. Sixty-seven of those rescued are unaccompanied minors.

“Simply, there’s a necessity today to get help to this ship,” Jean-Guy Talamoni, president of Corsica’s local assembly, told BFM-TV. “It’s time (Europe) wakes up and that everyone takes their share of responsibility. In the meantime, there are emergency situations, and you have to deal with them.”

In the coastal town of Sete near Montpellier in southern France, the port director also said he was ready to accept the Aquarius.

Earlier in the summer, Malta agreed to give safe harbor to a German aid group’s vessel Lifeline, but only after agreement that the 234 rescued migrants aboard would be distributed among Italy, Malta and seven other countries. So far 117 of the asylum-seekers have left Malta.

The German captain of the Lifeline has pleaded innocent in a Maltese court to charges he entered the island nation’s waters illegally and without proper registration, in a case that reflects Europe’s heightened determination to keep asylum-seekers from reaching the continent.

Many of the migrants are fleeing poverty in Africa and Asia and are eventually denied asylum, unlike those escaping wars or persecution.

Arrivals into Europe of migrants crossing the Mediterranean Sea from North Africa numbered just over 61,500 through Aug. 12, with 1,524 deaths reported, the U.N. migration agency said Tuesday.

That compares with more than 118,000 arrivals through the same period last year, and 265,640 in 2016.

Many migrants this year have headed to Spain, on what is known as the Western Mediterranean route, with 25,101 arrivals there, the agency said. Italy received 19,231, the second-highest number.

Quim Torra, the president of Spain’s Catalan region, offered three Catalan ports as safe harbor for the ship — setting himself apart from the Spanish government, which has remained silent on the vessel’s fate.

Spanish Prime Minister Pedro Sanchez’s minority government has come under political pressure over its migrant policy after it initially offered a generous welcome to asylum-seekers and refugees.

It is the second time in recent months that Aquarius has been caught up in the anti-migrant policies of EU nations. In a previous rescue mission, Spain allowed it to dock in Valencia in June with some 630 migrants aboard.

Torra’s regional administration is in a standoff with the central government over demands for Catalan independence and has been keen to score political points against Sanchez.