BRAZIL’S POLITICAL elite is being eaten alive by corruption scandals. The last three presidents have been accused of taking bribes, including incumbent Michel Temer, who took office last year following the impeachment of his predecessor. So have dozens of other senior politicians, including eight government ministers, two dozen senators and 39 members of Congress’s lower house. That’s not to mention the senior politicians in other Latin American countries, including Mexico, Colombia and Venezuela, accused of accepting graft from Brazilian companies.

The ever-expanding scandal is a credit to the strength of Brazil’s judicial institutions, and the housecleaning it is producing could ultimately strengthen the country’s 32-year-old democracy. But that might not happen if the scandal leads to chaos before it can produce desperately needed reforms. The 76-year-old Mr. Temer, an uncharismatic conservative with a 5 percent public approval rating, now stands at the center of that question.

Mr. Temer and a centrist congressional coalition were in the middle of trying to push through a revamping of social security payments and labor laws when the latest wave of scandal broke over them May 19. The Supreme Court released documents and tapes implicating Mr. Temer and former presidents Dilma Rousseff and Lula da Silva in accepting bribes from a meat exporting company; a tape also appeared to show Mr. Temer approving payoffs by the company’s president to an already-jailed congressman.

The president defiantly refused to resign and claimed the tapes had been doctored. But tens of thousands of demonstrators took to the streets of Brasilia, and Mr. Temer was forced to deploy the army last week after a government ministry was attacked and set on fire.

Whether Mr. Temer now becomes the second Brazilian president to be removed from office in less than a year depends less on the evidence than the intricacies of politics in Congress and the courts. Impeachment resolutions have so far been blocked by a presidential ally who is speaker of the lower house. But lawmakers are aware that the Supreme Electoral Tribunal, which has been considering a case to annul the last presidential election, could effectively remove the president from office early next month. Since Congress would then be charged with choosing a new president, behind-the-scenes bargaining has already begun over a successor.

Regardless of who is president, Brazil will have a government of dubious legitimacy until the next election, which is not until the end of 2018. The best outcome for the country would be for the centrist parties to work with whoever is in office to complete passage of the now-stalled reform bills. Unless the government can revise an unsustainable pension system and remove labor restrictions that choke private employment, Brazil’s economy will not be able to recover from the crushing recession it has endured for the past several years.

Political reforms, too, could help create a cleaner class of politicians. One obvious fix would be to raise the vote threshold for parties to obtain seats in Congress, where nearly two dozen different factions now are represented. Discredited though they are, Brazil’s politicians can still help their country if they pave the way for change.