Brazil's Supreme Court on Tuesday ordered the release from prison of Jose Dirceu, who was convicted of graft-related crimes after serving as cabinet chief of ex-president Luiz Inacio Lula da Silva.
Dirceu has been detained since 2015 in connection to a vast corruption scheme known as Car Wash.
A former guerrilla now aged 71, Dirceu was convicted in May 2016 to 32 years in jail for taking bribes, money laundering and criminal association.
The Supreme Court's judges ruled in a three-to-two vote he should be released because his conviction was not properly confirmed by a higher court.
The judge of the court that originally sentenced him in 2015 may yet put Dirceu under bail conditions, which can include house arrest or an electronic tracking bracelet.
Dirceu's release was seen as a blow to prosecutors handling the Car Wash case, Brazil's biggest-ever corruption scandal.
The probe has uncovered a massive network of embezzlement and bribery at the heart of Brazil's economic and political elite.
Lula, a leftwing leader who ruled 2003 to 2010, and a host of other political and business figures are also targets of anti-corruption prosecutors.
Lula's handpicked successor, Dilma Rousseff, was impeached and removed as president last year for the unrelated crime of breaking government accounting rules.
She was replaced by current President Michel Temer, who has been accused of chairing a 2010 meeting in which his PMDB party negotiated a $40 million bribe from the Odebrecht engineering conglomerate involved in the Car Wash scandal.
While Temer has immunity from prosecution for alleged crimes committed before his term, eight of his ministers are under investigation for related graft allegations.
Temer and his allies deny any wrongdoing.