The Dutch-flagged Sea-Watch 3 has been stuck in the Mediterranean, during a heatwave, since rescuing 53 migrants drifting in an inflatable raft off the coast of Libya on June 12.
The Sea-Watch 3 ship carrying dozens of rescued migrants forced its way into the Italian port of Lampedusa after a lengthy standoff and its captain has been arrested, the charity running the boat said Saturday.
Sea-Watch spokesman Ruben Neugebauer told AFP German captain Carola Rackete, 31, had been arrested after manoeuvring the ship into port without permission on Friday night.
Rackete - a hero to some but a "pain in the neck" to Italy's far-right Interior Minister Matteo Salvini - was detained for refusing to obey a military vessel, a crime punishable by between three and 10 years in jail.
Offering no resistance, she was escorted off the vessel without handcuffs and taken away in a car.
The 40 migrants still on board were eventually allowed to disembark early on Saturday and taken to the island's reception centre, some smiling, others in tears.
The Italian coastguard then took control of the boat, moved it out of the port again and anchored it just off the coast.
The ship docked despite the best efforts of a coastguard boat to prevent her from doing so by sailing back and forth between the vessel and the pier, according to the Repubblica daily.
Italian Prime Minster Giuseppe Conte, speaking on the sidelines of the G20 meeting in Osaka, Japan, said: "I don't want to take the place of the judiciary... But the laws exist, whether we like it or not."
While five European countries on Friday agreed to take in the migrants, permission for the Dutch-flagged Sea-Watch 3 to enter the port and disembark the migrants did not come.
Sources at the interior ministry, headed by Italy's far-right Matteo Salvini, said he was waiting for precise guarantees on "numbers, timelines and means" of the migrant redistribution before allowing them off.
"Even though in the afternoon the prosecution has opened an investigation against me, at the same time they notified us that they will not help to bring the rescued off the ship," Rackete said in a video statement on Twitter.
"I have decided to enter the harbour, which is free at night, on my own," she added.
Rackete had previously warned she was worried about the psychological condition of those rescued off crisis-hit Libya.
The ship and its captain were met by applause from a group of supporters standing on the pier on Lampedusa.
"It's been almost 60h since we declared a state of emergency. No one listened. No one took responsibility. Once more it's up to us, to Cpt. #CarolaRackete and her crew, to bring the 40 people to safety," the charity said on Twitter.
With Italy restricting port entry, the Dutch-flagged Sea-Watch 3 has been stuck in the Mediterranean, during a heatwave, since rescuing 53 migrants drifting in an inflatable raft off the coast of Libya on June 12.
The most vulnerable people onboard were evacuated, but Salvini insisted the rest were unwelcome.
On Wednesday, after over two weeks at sea, and as tempers on the small boat frayed, Rackete decided she had no choice but to enter Italian waters illegally to bring the remaining migrants to safety.