Updated at 1:57 p.m. ET

Former Brazilian President Luiz Inácio Lula da Silva was sentenced Wednesday to nine-and-a-half years in prison for his role in a massive corruption scandal, marking a remarkable turnaround for a political figure who less than two decades ago was being hailed as the architect of modern Brazil.

Judge Sergio Moro of the 13th Federal Court in Curitiba sentenced Lula, as he is known, for corruption related to the ownership of a luxury apartment in Guarujá, a resort town near São Paulo. Lula was accused in the case of receiving the apartment as an illegal gift for contracts obtained by OAS, the Brazilian conglomerate, with Petrobras, the state-owned energy giant. O Globo notes Lula is the first former president of Brazil to be convicted of corruption.

The BBC adds he will remain free pending an appeal.

Lula was charged last year in Operation Carwash, the Brazil’s largest-ever corruption scandal that has embroiled some of the biggest names in Brazil’s politics. Prosecutors allege Lula and his wife failed to disclose their ownership of the luxury apartment. Lula had denied the charges, calling them a politically motivated.

As my colleague Marina Koren previously reported:

Politicians across the political spectrum, including from Lula’s Worker’s Party, have been implicated in a money-laundering scheme at Petrobras, the state-run oil firm and largest company in Brazil. In 2014, investigators uncovered an alleged decade-old, secret network of bribes and kickbacks at the energy firm, in which executives overcharged the company for construction contracts and funneled the extra cash to themselves, others, or politicians.

Lula is a former trade-union leader who improbably ascended to the Brazilian presidency in 2003 and remade his country into a regional economic powerhouse. The conviction will likely tarnish his legacy, even though he remains personally popular and had hoped to lead the PT back to power in elections next year. He will be ineligible to seek the presidency if his conviction is upheld.