In Brazil’s Senate chamber Wednesday, dozens of lawmakers who have been charged with personal corruption voted to remove President Dilma Rousseff, who in five years in office was never accused of self-enrichment. Her departure was nevertheless probably the best available outcome for a country reeling from political scandal and the worst recession in a century. It was legal; it was politically legitimate; and it opens the way for reforms that Brazil desperately needs.

Rousseff has been claiming that her impeachment was a “coup” comparable to the removal by the military in 1964 of another leftist president, João Goulart. Her protestations have their own irony, in view of her government’s stout defense of Hugo Chávez’s dismantling of Venezuela’s democracy and its sweetheart deals with the Castro regime in Cuba.

But they are also false. Prosecutors presented substantial evidence that Rousseff violated a fiscal responsibility law in order to keep up government social spending before her 2014 re-election. As one prosecutor put it, “We are not dealing with a little accounting problem.”

Some legislators may hope to stop the corruption investigations, which have implicated hundreds of politicians. Yet what really sank Rousseff was her disastrous mismanagement of the economy, which included not just overspending but also a dogmatic policy of restricting contracting by the state oil company to domestic firms – the trigger for the massive outbreak of graft.

The president’s replacement, Michel Temer, is not much more popular than Rousseff. But he has encouraged Brazil’s business community with talk of sensible reforms, including cuts in state spending and in a pension system that rewards Brazilian seniors more than their counterparts in rich Japan. Temer’s problem will be persuading the Brazilian Congress, which resisted milder spending trims by Rousseff, to go along.

In nearby Argentina, voters have shown a willingness to accept painful fiscal measures by a new government because they promise to stabilize an economy wrecked by leftist populism. Brazilians and their leaders will need the same fortitude if the country is to reclaim its position as one of the world’s emerging powers.