RIO DE JANEIRO — It was anything but a surrender.
At times jovial and defiant, the former president of Brazil, Luiz Inácio Lula da Silva, stood before a crowd of cheering supporters, painting himself as the victim of a deceitful judiciary that had wandered dangerously into politics.
“If they think that with this sentence they will take me out of the game, let them know that I’m in the game,” Mr. da Silva said on Thursday, a day after his conviction on corruption and money laundering charges threatened his bid for a third presidency.
Corruption investigations have discredited virtually every powerful political force in Brazil, upending the country before presidential elections next year.
Now political adversaries on very different sides of the ideological spectrum are relying on the same survival strategy: attacking the legitimacy of prosecutors and judges who have set out to dismantle the culture of corruption that Brazilian politicians have institutionalized over decades.
The ruling against Mr. da Silva, one of Latin America’s most lionized and influential politicians, is the biggest conviction in a battle between the political class and a corps of judges and prosecutors — many of them in their 20s, 30s and 40s — who have dashed the impunity that elected officials have enjoyed for years.
On one side of the fight are veteran politicians like Mr. da Silva and the current president, Michel Temer, who faces the possibility of being ousted from office and sent to prison on corruption charges.
The two men, both in their 70s, are bitter political rivals who spent decades rising and falling in the highly fractured Brazilian party system, where fickle alliances are often sealed in back-room dealings and secret payoffs.
Standing against them are prosecutors and judges who argue that they are championing a more responsive vision of government. Preaching transparency, they are active on social media, openly encouraging Brazilians to make a united stand against graft.
“The faith in the political class is weakening, and this brings about a sense of confidence in the judiciary,” said Alan Mansur, the head of Brazil’s National Association of Prosecutors.
Dozens of lawmakers have been indicted or investigated in the past few years, for a range of crimes that include accepting unlawful campaign funds, soliciting bribes and laundering money.
And public opinion polls have shown that an overwhelming majority of Brazilians support the investigations rattling the political class. An Ipsos poll released in January found that 96 percent of respondents supported allowing the sweeping investigations that have caught up many political figures to continue “to the end, regardless of the outcome.”
Sergio Moro, 44, the judge who convicted Mr. da Silva, has become the most prominent figure in the crusade against corruption. Saying that he took no pleasure in sentencing a former president to almost 10 years in prison, Judge Moro invoked a saying by the 17th-century English historian Thomas Fuller to underscore the ruling: “Be you never so high the law is above you,” he wrote.
As the corruption cases overseen by Judge Moro have ensnarled an ever-growing class of powerful Brazilians, the judge has become something of a folk hero in the country. And in legal circles abroad, he is sometimes hailed as a transformational force for Brazil.
But Mr. da Silva, who helped lift millions out of poverty as president from 2003 to 2010 and still commands the loyalty of many Brazilians, argues that judges and prosecutors are pursuing him in court because they do not have the support to beat him at the ballot box.
On Thursday, in remarks at his party headquarters in São Paulo that often felt like a campaign rally, Mr. da Silva painted himself as the victim of a politically motivated judiciary that would fail in its efforts to derail his bid for the presidency.
He joked one moment, bragging that he had not even bothered to read the 218-page verdict that condemned him to nearly a decade in prison because he had been busy watching his favorite soccer team.
Then, in an attack on the integrity of the justice system, he invoked his poor upbringing and his mother’s legacy. “I learned about honesty from an illiterate woman,” Mr. da Silva said, his eyes welling up.
The theme of unfair judicial interference has given staunch political rivals common ground.
After Mr. da Silva’s conviction, Mr. Temer’s lawyer, Antonio Cláudio Mariz de Oliveira, told reporters that the two veteran politicians were being targeted by prosecutors who were accusing “innocent people” and “destroying reputations” with “hasty allegations.”
Prosecutors and judges reject the claims that they are acting as political kingmakers, not unbiased defenders of the law.
“Defendants are being prosecuted in almost every political party,” said Mr. Mansur, the head of prosecutors association. “This shows that it is not about a preference for a political party or the persecution of a political party.”
State prosecutors charged Mr. da Silva with money laundering and corruption, accusing him of accepting costly upgrades to a beachfront apartment from a construction company. In exchange, prosecutors said, the company received lucrative contracts from the state-owned oil company, Petrobras.
Mr. Temer was charged last month by federal prosecutors who accuse him of condoning bribes to a jailed politician in order to obstruct a corruption investigation. Both cases stem from a sweeping investigation into corruption involving Petrobras.
Transparency International, an anti-corruption watchdog, applauded the conviction against Mr. da Silva. Bruno Brandão, the head of the organization’s office in Brazil, called the verdict a transformational moment for the country.
“The centuries-old impunity of the elite classes in Brazil is being dismantled,” he said.
Mr. da Silva’s fate is now in the hands of a panel of three judges in the southern city of Porto Alegre. On Thursday, the head of that appeals court said he expected that the court would decide the case before Aug. 15, 2018, the deadline to register as a presidential candidate.
If the court upholds the verdict, Mr. da Silva, one of the founders of the leftist Workers’ Party, could spend nearly 10 years in prison. If the conviction is overturned, the canny politician could return to power and lead Brazil once more.
Mr. Brandão said that the appeals court in Porto Alegre was well regarded in legal circles and that it tended to uphold Judge Moro’s decisions more often than it has overturned them.
“In general, it is a court that is very well prepared,” Mr. Brandão said. “The judges are very discreet. They don’t appear in the media, and virtually no one in the Brazilian population knows these judges by name. The more anonymous the judges, the better it is for justice.”
Some politicians welcome the shake-up — and stand to benefit from it.
Marina Silva, a former member of Mr. da Silva’s cabinet who broke ranks with his Workers’ Party in 2009, said the scandals plaguing Brazil’s dominant political parties could be a catalyst for a sweeping transformation that the country needs.
“Brazil’s current crisis requires the reinvention of politics,” said Ms. Silva, who ran for president in 2014 and is widely expected to enter the race next year. “This debate is not limited to Brazil, but extends to the world.”