Sao Paulo: Former Brazil president Michel Temer left prison on Wednesday less than a week after returning to a Sao Paulo penitentiary in relation to a wide-ranging corruption scandal that has engulfed several high profile South American politicians.
The 78-year-old left the Military Police Battalion in Sao Paulo at 1.30 pm (1630 GMT) in a heavily guarded convoy as he headed to his home in an upmarket neighborhood in the sprawling city's west.
His release was ordered by all four judges on the Superior Court of Justice under the writ of habeas corpus, which demands that a prisoner who claims unlawful detention be brought before a court.
However, several conditions were attached, including a freezing of his assets and the seizure of his passport.
Temer has been implicated in an investigation into alleged bribes made in 2014 in exchange for work contracts at the Angra 3 nuclear power plant in Rio de Janeiro state.
He was first placed in "preventative detention" in Rio de Janeiro in March.
That decision was overturned days later by another judge, only for an appeals court to order him back to jail last week.
He is suspected of having been at the head of a criminal organisation that diverted up to 1.8 billion reais ($460 million) and has been operating for 40 years.
Temer is the subject of five lawsuits and an investigation, mostly related to passive corruption and money laundering.
He was the second ex-president of the Latin American country to be caught up in a sprawling anti-corruption probe called Operation Car Wash that has claimed scores of political and corporate scalps.
Leftist former president Luiz Inacio Lula da Silva was jailed in April 2018 for bribery and money laundering as part of the probe.
Temer came to power in August 2016 after Lula's hand-picked successor Dilma Rousseff was impeached for alleged financial wrongdoing in office.
He was succeeded by far right leader Jair Bolsonaro on January 1.