Mr. da Silva’s Workers’ Party responded defiantly to the ruling on Wednesday afternoon and called on supporters to take to the streets.
“If they think this story ends with today’s decision they’re sorely mistaken,” the party said in a statement. “We won’t give up in the face of this injustice.”
Mr. da Silva, 72, looked drained but sounded resilient when he addressed supporters in São Paulo on Wednesday night.
“Mandela was sent to prison and then he came back and became president of South Africa,” a hoarse-sounding Mr. da Silva said.
An election victory by Mr. da Silva would be a dramatic return to power for him and his party two years after the impeachment of his protégé, Dilma Rousseff. Her removal elevated Mr. Temer, of the center-right Brazilian Democratic Movement party, to the presidency.
Federal Judge Sérgio Moro, the most prominent figure in the judiciary’s crackdown on political corruption, convicted Mr. da Silva in July on corruption and money laundering charges for accepting bribes from O.A.S., a major construction company, in the form of a seaside apartment that was being renovated to his liking. The judge sentenced Mr. da Silva to nearly a decade in prison, but ruled that he should remain free pending appeals.
Mr. da Silva has called the conviction a miscarriage of justice orchestrated by underhanded political actors within the judiciary.
“We will continue to fight this political conviction,” Cristiano Zanin Martins, Mr. da Silva’s lawyer, said in a statement on Wednesday. “And we will win this fight, not just for Lula but for all Brazilians who believe that the rule of law and democracy must prevail.”
Mr. da Silva’s supporters claim that he never lived in, or took ownership of, the renovated apartment at the heart of the case. They have cast doubt on the reliability of witnesses who implicated him, asserting that the witnesses testified in return for leniency in their own corruption cases.
They have also noted that politicians accused of more egregious wrongdoing — including President Temer, who was recorded appearing to condone the payment of a bribe — have so far dodged accountability.
The three-judge panel that considered Mr. da Silva’s appeal included two jurists appointed by the former president’s political ally, Ms. Rousseff: João Pedro Gebran Neto and Leandro Paulsen. The third judge, Victor Laus, was appointed by the former President Fernando Henrique Cardoso.
“There is evidence that established beyond a reasonable doubt that the ex-president was one of the leaders, if not the leader, of a vast corruption scheme,” Judge Gebran Neto said during the hearing. “At a minimum, the evidence shows that he was aware of it and supported it.”
Anamara Osório Silva, the president of the National Association of Prosecutors, denounced what he said were efforts to impugn the integrity of the judiciary.
“This is not a politicized prosecution, it is the prosecution of a politician accused of committing grave crimes,” Ms. Osório said Wednesday. “No one can be beyond the reach of an independent judicial branch. No one will intimidate or weaken the resolve of our prosecutors.”
Mr. da Silva is expected to argue before Brazil’s Superior Electoral Court and the Supreme Federal Court that disqualifying him from running in the election would subvert democracy. Political analysts and legal experts in Brazil say that ultimately the Supreme Court is likely to resolve the matter.
Mr. da Silva is not expected to be jailed while appeals are pending. His backers have warned that imprisoning the former president, who governed Brazil from 2003 to 2010, would set off a severe response from Workers’ Party loyalists, known by its initials in Portuguese, P.T.
“The reaction from the P.T. would be to grab him from prison,” Senator Gleisi Hoffmann, the president of the party, said in an interview last year. “There’s a culture in Brazil on this issue of arresting a president, an ex-president, that I think that even the armed forces would not allow it.”
Senior politicians and Brazilian scholars have warned in recent days that barring Mr. da Silva from running would further undermine faith in the country’s young democracy, which has been rocked in recent years by the impeachment of Ms. Rousseff and by the sprawling corruption inquiry known as Lava Jato, or Car Wash, that began in 2014.
Mr. Temer said last week that he hoped Mr. da Silva would be allowed to run.
“I think if Lula participates, it would be a democratic thing, the people will say whether they want him or not,” the president said in an interview with the Folha de São Paulo newspaper that was published on Saturday. “If he is defeated politically it is better than being defeated” in the courts, which would make him seem like a victim, the president added.
Mr. da Silva is expected to travel to Ethiopia later this week for a meeting with African leaders.
During a meeting with journalists last week, the former president, who rose to prominence as a union activist during Brazil’s 1964-85 military dictatorship, characterized the case against him as merely the latest form of persecution he has faced.
“I think that those who accuse me today are more worried than I because I have the peace of mind of those who are innocent,” Mr. da Silva said. “And they must be feeling the guilt that comes from lying.”
Fans and critics of the former president took to the streets in São Paulo and Porto Alegre after the decision was announced to celebrate and denounce the ruling. Leonardo Gregory Brunnet, a 60-year-old physicist from Porto Alegre, said the prosecution of Mr. da Silva left him feeling drained.
“The verdict doesn’t strike me as a blow against corruption,” said Mr. Brunnet, who said he had lost faith in the Workers’ Party because he felt it did not do enough to reduce inequality. “It strikes me as a reflection of a profoundly divided society.”