Brazil's former president Luiz Inacio Lula da Silva is set to walk out of prison after a judge ordered his release.
Federal police have to comply with Friday's order "with urgency," the decision says.
Hundreds of supporters have gathered outside the federal police building in Curitiba, hoping the 74-year-old politician could walk out free at any moment. A stage has been set up for him to address the crowd if he does.
Da Silva has been detained since April 2018 after being convicted of corruption and money laundering.
The move follows a Supreme Court decision Thursday that a person can be imprisoned only after all appeals to higher courts have been exhausted. Da Silva is still appealing the case that put him behind bars, related to the alleged purchase of a beachfront apartment in Sao Paulo state.
If he exhausts his appeals, he could find himself back in prison.
The former leader, who governed from 2003 to 2010, had been favoured to win the 2018 presidential election, but his conviction prohibited him from running.
Da Silva tweeted "Lula Free" with a video of himself working out and lifting weights in a gym. The former president is universally known in Brazil as Lula.
It is not yet clear what political role Da Silva will seek to occupy now that he is free. The former leader of the leftist Workers' Party, better known in Brazil by its Portuguese acronym PT, remains a popular figure on the left, whose politicians and voters have ceaselessly called for his release.
Political analysts believe Da Silva could rally the opposition, which has been demoralized by the corruption scandals, impeachment of Da Silva's hand-picked successor, Da Silva's imprisonment and, more recently, a clobbering in the 2018 general elections.
Aside from his promise to root out corruption and curb violence, far-right President Jair Bolsonaro ran a strong campaign on anti-Workers Party sentiment. He won the election with 55 per cent of the vote and was sworn in on Jan. 1.
The former president has said that when free, he would travel around the country rallying opposition. Political analysts say he might not immediately enter into frontal opposition with Bolsonaro, seeking instead to influence the next presidential election in 2022.
"The thing that makes Lula most dangerous to Bolsonaro is that Lula understands the long game," said James Bosworth, founder of Hxagon, a political risk analysis firm, stressing that the politician had run four times before being first elected in 2003.
"Lula is an old-school union and political organizer who is going to take his time placing PT and other allies into positions to take advantage of Bolsonaro's weaknesses in the coming years," he said.
The former union leader is widely referred to as a "political animal." He presided over a period of rapid economic growth fuelled by a commodities boom that expanded the country's middle class. His huge Bolsa Familia welfare program helped lift millions from poverty, and he left office with an approval rating above 80 per cent.