Brazil's ex-president Michel Temer handed himself in to police in São Paulo on Thursday, the day after a court ordered his return to prison.
Temer, 78, arrived at federal police headquarters in São 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 Lava Jato ("Car Wash") that has claimed scores of political and corporate scalps.
He is suspected of having been at the head of a "criminal organisation" that diverted up to 1.8 billion reais (US$460 million.)
Colonel Joao Baptista Lima Filho, Temer's close associate and a suspect in the case, has also been issued a warrant.
A Rio de Janeiro appeals court on Wednesday ordered Temer back to jail with "immediate effect," a court official told AFP, 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 São 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 Lava Jato 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.
Leftist former president Luiz Inácio Lula da Silva was jailed in April 2018 for bribery and money-laundering as part of the Lava Jato 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.