Brazil's full Supreme Court upheld a ruling annulling former president Luiz Inacio Lula da Silva's corruption convictions, which cleared the way for him to run for a new presidential term next year.

In an 8-3 ruling, the court upheld Justice Edson Fachin's 8 March decision quashing Mr Lula's convictions on procedural grounds, which has upended Brazilian politics as President Jair Bolsonaro gears up to seek re-election.

The ruling does not find Mr Lula innocent. But it essentially puts prosecutors back to square one by sending the cases to another court.

In the meantime, Mr Lula, who led Brazil through an economic boom from 2003 to 2010, has emerged as the top contender to unseat Mr Bolsonaro in the October 2022 elections.

Mr Lula's lawyers called the decision "historic".

"This is another Supreme Court ruling that reestablishes the credibility of the justice system in our country," they said in a statement.

Mr Bolsonaro said the ruling means "Lula is now a candidate" for 2022, and warned of the consequences.

"Look what Brazil's future is going to be like with the kind of people he'd bring into the presidency," he said in his weekly live address on Facebook. "You can all draw your own conclusions."

Mr Lula, 75, has not officially declared himself a candidate. But polls put the steelworker-turned-president neck-and-neck with 66-year-old Mr Bolsonaro, and in some cases ahead.

Mr Lula was jailed in 2018 on charges of taking bribes from companies seeking lucrative contracts at state oil giant Petrobras.

Prosecutors say he accepted gifts including a triplex beach apartment and renovations at a ranch property in exchange for easing companies' access to contracts with state oil giant Petrobras.

The cases felled him just as he was gearing up to seek a new presidential term, in elections Mr Bolsonaro ultimately won.

Brazillian President Jair Bolsonaro

Mr Lula has always maintained he is innocent and that the cases against him were a conspiracy to sideline him politically.

After Mr Justice Fachin's initial ruling annulling his convictions, he came out swinging at Mr Bolsonaro, attacking the president's "imbecile" handling of the coronavirus pandemic, which has claimed 365,000 lives in Brazil - the world's second-highest death toll.

"Don't be scared of me. They say I'm a radical because I want to get to the root of this country's problems," he said in his comeback press conference, which analysts called a campaign speech in all but name.

The charges against Mr Lula grew out of "Operation Car Wash," an investigation that blew the lid off a massive corruption scheme in which top politicians and business executives systematically siphoned billions of dollars from Petrobras.

Mr Justice Fachin ruled the court in the southern state of Parana that handled the Car Wash cases did not have jurisdiction for Mr Lula's charges because they were not directly related to the Petrobras scheme.

He ordered the four cases - two convictions and two pending judgments - transferred to another court.

Prosecutors had asked the Supreme Court to at a minimum reinstate the two convictions, arguing they were legally sound and that Mr Lula was "named as the ringleader" of the Petrobras scheme - an accusation they have struggled to pin on him in court.

Mr Lula spent 18 months in jail before being freed in 2019 pending appeal. The full Supreme Court is also due to rule on prosecutors' appeal of a decision that found the lead Car Wash judge, Sergio Moro, was biased in convicting Mr Lula.

They set deliberations on that case for next Thursday. Mr Moro controversially accepted the post of justice minister in Mr Bolsonaro's government when the latter won the 2018 election.

That fuelled accusations he colluded to sideline Mr Lula and get Mr Bolsonaro elected.

Mr Moro later had a falling-out with Mr Bolsonaro, accusing the president of interfering in federal police investigations. He resigned in April 2020.