WASHINGTON — The rule of law and the independence of the judiciary are fragile achievements in many countries — and susceptible to sharp reversals.

Brazil, the last country in the Western world to abolish slavery, is a fairly young democracy, having emerged from dictatorship just three decades ago. In the past two years, what could have been a historic advancement — the Workers’ Party government granted autonomy to the judiciary to investigate and prosecute official corruption — has turned into its opposite. As a result, Brazil’s democracy is now weaker than it has been since military rule ended.

This week, that democracy may be further eroded as a three-judge appellate court decides whether the most popular political figure in the country, former President Luiz Inácio Lula da Silva of the Workers’ Party, will be barred from competing in the 2018 presidential election, or even jailed.

There is not much pretense that the court will be impartial. The presiding judge of the appellate panel has already praised the trial judge’s decision to convict Mr. da Silva for corruption as “technically irreproachable,” and the judge’s chief of staff posted on her Facebook page a petition calling for Mr. da Silva’s imprisonment.