Brazil’s supreme court has reached a narrow decision that could release almost 5,000 inmates who are still appealing their convictions, including jailed former president, Luiz Inácio Lula da Silva.

The court decided in a 6-5 vote on Thursday that a person can be imprisoned only after all appeals to higher courts have been exhausted. The tie-breaking vote was cast by chief justice, José Dias Toffoli.

The decision appears to cover Silva and others convicted in cases arising from the Operation Car Wash corruption investigation, which has ensnared dozens of top politicians and business leaders in Latin America’s biggest nation.

The supreme court’s debate began in mid-October and its result could throw Brazil’s political landscape into uncertainty.

Silva, universally known as Lula, had been favoured to win the 2018 presidential election, but his conviction prohibited him from running. He remains a popular figure on the left, whose politicians and voters have called for his release.

The former president’s attorneys said in a statement they will request his release on Friday. That move initially depends on a judge based in the southern city of Curitiba, where he is jailed.

Prosecutors from the Car Wash probe said in a statement that the decision “goes against the sentiment of repudiating impunity and the fight against corruption”.

Many of powerful Brazilians imprisoned in the investigation will be able to seek release under the ruling.

The decision marks a key change for Brazil’s top court, which in February 2016 accepted that defendants who have a conviction upheld may be jailed even their if other appeals are pending decisions. Brazil’s constitution states that no one can be considered guilty until due process is concluded.

The court confirmed that verdict on three other occasions, and as recently as April.

Justice Gilmar Mendes, who voted for the release of inmates who have yet to conclude their appeals process, said Silva’s case “contaminated” debate on the issue.

“That was not good at all for rational debate,” said Mendes, an open critic of the Car Wash probe, during the full-court session.

Lula was jailed in April 2018 after a group of judges upheld his conviction for corruption and money laundering. His first conviction was issued by Sergio Moro, then a judge on a low court and later named justice minister by President Jair Bolsonaro.

Lula, who governed from 2003 to 2010, is still appealing against a case related to bribes he allegedly received in the form of a beachfront apartment prosecutors said was renovated for him and his wife in the city of Guarujá, in São Paulo state, in Brazil’s two high courts. He was also sentenced by a low court judge in a case regarding alleged ownership of a farmhouse in the city of Atibaia, outside São Paulo.

The 74-year-old politician has denied any wrongdoing in those cases. He accuses Moro and Car Wash prosecutors of political persecution.

Brazil’s justice council estimates at least 4,895 prisoners stand to benefit from the court’s decision on appeals.