Brazil’s Supreme Court is ruling on former President Luiz Inacio Lula da Silva’s plea to remain at liberty despite a lengthy prison sentence, a decision likely to shape the outcome of October’s elections and mark the culmination of an epic corruption scandal.

By 8pm on Wednesday evening five of the court’s 11 judges had voted on Lula’s request to stay out of jail despite losing an appeal against a criminal conviction for corruption and money-laundering. Four had voted against his plea, including the judge considered the swing vote on the court. Lula says he should not be imprisoned until he has exhausted all chances for appeal. He is currently the front-runner in opinion polls for October’s presidential election, though it is highly likely he will be barred from taking part.

Luiz Inacio da Silva

Photographer: Andre Coelho/Bloomberg

The court’s decision could pave the way for the once hugely popular president to be put behind bars and become the highest-profile casualty of Operation Carwash, the four-year long corruption investigation that has shaken Brazil’s culture of impunity. Since leaving office in 2010 with sky-high approval ratings, the former trade unionist has become a deeply polarizing figure, still beloved on the left for the legacy of his social policies, but reviled by the right for the corruption that flourished under 13 years of Workers’ Party rule. Investors are wary of his pledge to undo recent pro-market policies.

"The biggest risk scenario is if Lula is successful in his plea and able to run for president," said Erik Nelson, a currency strategist at Wells Fargo. "Most polls at the current juncture suggest he would do well in most election scenarios." Brazilian assets drifted on Wednesday, with stocks going sideways and the real appreciating somewhat as the hearing continues.

In a sign of growing tension, Brazil’s Army chief on the eve of the court hearing issued a veiled warning. Without mentioning the case, General Eduardo Villas Boas wrote on his Twitter account that the Brazilian Army was mindful of its institutional mission and shares the wish of all good citizens in repudiating impunity. Brazil’s current situation, he wrote, begs the question who is thinking about the well-being of the country and who is only concerned with personal interests.

Pro- and anti-Lula protesters gathered in some of the country’s main cities on Tuesday evening. In a highly unusual move, the president of the Supreme Court, Carmen Lucia, gave a televised address on Monday appealing for calm. Last week, two of Lula’s campaign buses were hit by gunfire while traveling in the southern state of Parana.

Further demonstrations are taking place in Brasilia on Wednesday in an attempt to influence a decision that will send shock waves across Latin America’s largest economy, whatever the result. While Lula and his supporters argue the charges against him are politically motivated, opponents insist his imprisonment represents progress for justice in the country.

Brazil’s top electoral court, rather than the Supreme Court, will decide whether Lula can run in this year’s election. As the law stands, he should be ruled out on the basis of his criminal conviction, but a decision will only come after the Aug. 15 deadline for registering candidates.

Aside from Lula’s specific case, the Supreme Court may also rule on the general principle of whether convicted criminals can remain at liberty until they have exhausted the appeals process, a judgment with widespread implications.