A Brazilian judge has sentenced former socialist Workers’ Party (PT) president Luiz Inácio Lula da Silva of Brazil to nine and half years in prison on charges of corruption and money laundering.

Prior to his conviction, Lula had been leading polls as a potential candidate for president during the next round of national elections.

The judge in the case, Sergio Moro, has become a folk hero among anti-government Brazilians for having taken the lead in investigating a corruption scheme known as “Operation Car Wash,” in which dozens of government officials were accepting bribes and kickbacks as part of a larger scheme run using the state-controlled oil corporation Petrobras. That scheme took shape under Lula’s presidency, and Moro’s revelations fueled millions-strong protests against Lula’s successor, Dilma Rousseff, who was impeached for unrelated fiscal improprieties.

Moro’s investigations led to the architect of her impeachment, former Speaker of the House Eduardo Cunha, also being arrested and sentenced to prison on corruption charges.

According to Moro’s ruling, Petrobras had significantly overpaid on multiple contractor projects over the years; the contractors would then give some the extra money back to politicians as a kickback to ensure that they would receive continued business. Lula, the ruling states, personally benefitted from this scheme, purchasing a luxury triplex apartment with the money.

The Brazilian magazine Veja reports that Moro and his team found that Lula personally had a hand in diverting 87 million reais, or about $26 million, in Petrobras funds.

“Upon assuming the office of the presidency of the Republic, Lula ordered the formation of a criminal scheme to divert public resources destined to illicitly enrich as well as ensure criminal perpetuation in power, buy parliamentary support, and finance expensive electoral campaigns,” the prosecution wrote in the case.

Lula, prosecutor Deltan Dallagnol concluded, was “the maestro of this grand orchestra.”

The Brazilian publication Folha de Sao Paulo adds that Lula will not be imprisoned just yet, as the case allows him one appeal before he serves his sentence. “If the confirmation of the sentence upon appeal does not occur before the October 2018 election, he will… be able to run as a candidate,” the newspaper adds. A national poll released in June found that 30 percent of voters would consider Lula their first choice in that campaign. As president, Lula was a staunch supporter of Latin American leftists in Cuba, Venezuela, and Argentina, and if reelected would provide Venezuelan dictator Nicolás Maduro with a much-needed ally on the international stage, particularly in the Organization of American States (OAS).

O Globo notes that this is the first time in the history of the country that a former president has been convicted on corruption charges.

Lula has maintained his innocence throughout the accusations, sobbing in public and comparing himself to Jesus Christ.  “I am proud to have created the most important leftist party in Latin America, and having created the party when many people thought it impossible to create,” he said in response to the charges in September. While testifying, Lula compared the legal process to a “massacre.”

During the investigation, then-president Dilma Rousseff attempted to protect Lula from the charges by appointing him her chief of staff, thus granting him executive immunity. A court invalidated the move, while Moro released a wiretapped conversation between the two that appeared to prove the only purpose of the hire was to obstruct justice by granting him immunity.

Follow Frances Martel on Facebook and Twitter.