The man known to Brazilians simply as Lula remains revered both for his economic policies and his role in fighting for democracy during the country’s dictatorship.

Former Brazilian President Luiz Inacio Lula da Silva was found guilty of corruption and money laundering on Wednesday and sentenced to almost 10 years in prison, the highest-profile conviction yet in the sprawling graft investigation that has jailed dozens of Brazil’s elite.

The decision by Judge Sergio Moro was widely expected, even by Silva’s own defense team, but was still stunning. The charismatic leader left office on Dec. 31, 2010, with sky-high popularity and is credited with pulling millions of Brazilians out of poverty and turning Latin America’s largest nation into an important player on the world stage.

Brazil’s first working class president will remain free while an appeal is heard, but he is now also the country’s first ex-president to be convicted in a criminal proceeding at least since democracy was restored in the 1980s.

In many quarters, the man known to Brazilians simply as Lula remains revered both for his economic policies and his role in fighting for democracy during the country’s dictatorship. The 71-year-old has been considered a front-runner for next year’s presidential election.

Silva’s defense team issued a scathing statement after the ruling, calling the charges an attack on democracy and vowing to prove the former president’s innocence.

“President Lula has been the victim of lawfare, the use of the law for political ends, the famous method used to brutal effect in various dictatorships throughout history,” the lawyers said.

The case is part of the huge “Operation Car Wash” corruption investigation centered on state-run oil giant Petrobras that has led to the convictions of dozens of business executives and politicians, and threatens current President Michel Temer.

Silva was accused of receiving a beachfront apartment and repairs to the property as kickbacks from construction company OAS. Silva never owned the apartment, but prosecutors argued it was intended for him. Prosecutors also alleged that OAS paid to store Silva’s belongings, but Judge Moro dismissed that part of the case.

Silva also faces charges in four other cases. The former union leader has said all the charges are completely unfounded, and his defiant testimony in the case decided on Wednesday was billed as a showdown between himself and Judge Moro. Both men are viewed as national heroes by some parts of Brazilian society.

“The present conviction does not bring this judge any personal satisfaction. Quite the contrary, it is regrettable that a former president be criminally convicted,” Judge Moro wrote in his decision. “It doesn’t matter how high you are, the law is still above you.”

Judge Moro said he did not order Silva’s immediate arrest because the conviction of a president is such a serious matter that he felt the former leader’s appeal should be heard first.

“This makes Lula’s situation much worse since it is much more than a mere investigation,” said Claudio Couto, a political science professor at Fundacao Getulio Vargas, a Sao Paulo-based university and think tank. “But now he will do something he likes- Until the appeal is decided, he will rally his allies and supporters against a decision that is controversial.”

A few hundred supporters gathered in Sao Paulo on Wednesday night to denounce the ruling. A smaller group of people also rallied to support it.

“It was an obviously political decision to prevent Lula from becoming president,” said Armando Teixeira, an unemployed auto worker. “Everyone knows he will win if he runs.”

The case now goes before a group of magistrates. If they uphold the conviction, Brazilian law says Silva would be barred from seeking office. In addition to sentencing Silva to 9 1/2 years in prison, Judge Moro also ruled that the politician should be barred from public office for 19 years.

Silva’s presidency coincided with an economic boom fueled by high commodity prices and he used the profits to fund generous social programs that made him a hero among Brazil’s poor. He left office with popularity ratings of up to 87 per cent and Brazilians elected his hand-picked successor, Dilma Rousseff, to succeed him.

But a subsequent fall in commodity prices and economic mismanagement by Silva and Ms. Rousseff led Brazil’s economy to implode, and with it Ms. Rousseff’s popularity. Ms. Rousseff was later impeached and replaced by Mr. Temer.

The news of Silva’s conviction took the focus off of Mr. Temer, who himself is accused of taking bribes from a meatpacking executive in exchange for helping the company obtain favorable government decisions. Mr. Temer denies wrongdoing, and the lower house of Congress will decide if he should be suspended from office and put on trial.

A close Mr. Temer ally got some relief on Wednesday. A judge ordered former Legislative Affairs Minister Geddel Vieira Lima released from jail and instead put under house arrest while he faces an obstruction of justice charge.