Brazil's ex-president Michel Temer handed himself into police in Sao Paulo on Thursday, the day after a court ordered his return to prison. Temer, 78, arrived at federal police headquarters in Sao Paulo in a convoy of vehicles, two hours before a deadline.
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.
He is suspected of having been at the head of a criminal organization that diverted up to 1.8 billion reais (US$460 million).
A Rio de Janeiro appeals court on Wednesday ordered Temer back to jail with immediate effect, a court official said, just weeks after he was freed by another judge.
Temer, who is accused of leading a sophisticated embezzlement and money laundering scheme, was arrested in Sao Paulo in March and placed in preventative detention in Rio de Janeiro.
But that decision was overturned four days later by another judge, citing a lack of legal justification.
It's an unpleasant surprise for me but I'll willingly turn myself in tomorrow, Temer said on Wednesday evening outside his home.
There's no basis to this incarceration. The judges themselves say there's no risk of Temer fleeing the country or destroying evidence, his lawyer Eduardo Carnelos said.
The argument is that an example has to be made for society. This is another sad page in the recent history of Brazilian justice.
Since 2014 the Car Wash probe has uncovered a vast graft operation involving state oil firm Petrobras and major construction companies paying bribes to politicians of several parties.
More than 150 people have been convicted and hundreds more charged so far, including ex leftist president Lula da Silva, jailed for bribery.