Italy's highest court on Friday agreed that Carola Rackete, the German captain of a migrant rescue ship, should not have been arrested for forcibly docking in Sicily.
"This is an important verdict for all sea rescue activists!" Rackete said on Twitter.
"No one should be prosecuted for aiding people in need. The EU directive on 'crimes of solidarity' needs reform," she said.
The dreadlocked Rackete was skipper of the Sea-Watch 3, one of several ships used by international charities to rescue migrants attempting the perilous sea journey from North Africa to Europe on rickety boats.
On June 12, Rackete's ship picked up 53 migrants adrift aboard an inflatable raft off the coast of Libya.
The Italian authorities allowed some of the migrants to be taken in for health reasons but refused entry to more than 40 others, leading to a two-week stand-off at sea.
As conditions on board worsened, Rackete eventually sailed her ship to the island of Lampedusa despite an order from Italian officials not to dock there.
She was arrested on June 29, although a judge overturned that order on July 2, saying she had acted "out of necessity" because of the migrants' condition.
The high court Friday ruled that Rackete's arrest was not warranted.
Sea-Watch, the charity which runs the rescue ship, welcomed the ruling, tweeting: "Once again: Sea rescue is not a crime!"
Rackete became a left-wing hero in Italy for challenging then far-right interior minister Matteo Salvini's "closed ports" policy.
Salvini is facing a potential trial for allegedly illegally detaining migrants at sea.
A tribunal has recommended he stand trial for blocking migrants on a coastguard boat last July. But under Italian law ministers cannot be tried for actions taken in office unless a parliamentary committee gives the go-ahead.
The committee is due to take a decision on Monday, though that may be postponed.
Should the trial go head, Salvini faces up to 15 years in jail if found guilty.
"For some judges a German lady, who risked killing five Italian soldiers by ramming their patrol boat, doesn't deserve jail time, but the minister who blocked dockings and human trafficking does," Salvini said on Twitter.
"That's not justice, that's a crying shame," he said.
Salvini has accused his successor of re-opening the ports to rescued migrants, prompting more departures from Libya.
But Matteo Villa from the Institute for International Political Studies dismissed the alleged "pull factor", and pointed out last week that while the number of arrivals dropped under Salvini, the death toll in the Mediterranean rose.
It has dropped sharply since he left office.
In the early hours of Friday the Ocean Viking rescue ship pulled 39 people to safety from a rickety wooden boat off Libya which had begun taking in water.
Medical charity Doctors Without Borders, which charters the ship along with SOS Mediterranee, said the rescue had been particularly "challenging" due to rough seas and fierce winds.