IN FEBRUARY Rafael Correa, Ecuador’s then-president, compared the country’s run-off election to the battle of Stalingrad. “We are going to fight the worldwide right wing,” he said. His man, Lenín Moreno, duly scored a narrow victory against Guillermo Lasso, a conservative banker. Yet with Mr Moreno in office for less than five months, Mr Correa has now turned his rhetorical fire against his former ally, calling him “a hypocrite” and a “compulsive liar” who has achieved “what the opposition didn’t manage in ten years, to discredit our revolution”.

Mr Correa is alarmed because, to the surprise of many, Mr Moreno has turned out to be his own man with his own ideas. And that has implications beyond Ecuador, a country of 17m people that was notorious for political instability before Mr Correa took charge in 2007 as part of a wave of populist leftist leaders in South America. Benefiting from an oil windfall, he ruled as a paternalist autocrat. In what he called a “citizens’ revolution”, he invested in schools, hospitals and motorways. He was intolerant of criticism, persecuting opponents and imposing restrictions on the media.

When the oil price fell in 2014, the economy weakened and opposition to Mr Correa grew. He pushed through a constitutional change abolishing presidential term limits, but only from 2021, opting to step back rather than risk defeat. Trusting in his grip on the ruling Alianza PAIS (AP) party and in Jorge Glas, a close collaborator who was Mr Moreno’s running-mate, Mr Correa moved to Belgium, his wife’s country.

In Mr Moreno, his vice-president in 2007-13, Mr Correa chose an electorally effective successor—but not a pliant placeholder. “Correa knew that on many things I disagreed with him,” Mr Moreno told the BBC recently. By acting on those differences, Mr Moreno, who has used a wheelchair since he was shot in an attempted robbery in 1998, has swiftly established his own leadership.

Where Mr Correa was a tub-thumping polariser, Mr Moreno is a soft-spoken consensus-maker. He has built bridges with the opposition, businessmen and civic groups. He has turned Ecuadoreans’ anger over corruption to his political advantage. He stripped Mr Glas of most of his powers and authorised prosecutors to proceed against him. This month Mr Glas was detained on suspicion of taking bribes from Odebrecht, a Brazilian construction firm (which he denies). In all, two dozen officials who had served in Mr Correa’s governments face corruption charges.

All this has made Mr Moreno wildly popular. His approval rating is 77%, according to Cedatos, a pollster. That, in turn, has allowed him to start to wrest control of the AP party, which holds a majority in congress. Mr Moreno is seeking to press his advantage with a referendum on constitutional changes to be held early next year. One would restrict presidents to two terms, thus barring Mr Correa from running again. Another would replace the seven members of a body set up by Mr Correa’s constitution, which controls appointments to the judiciary, the electoral authority and the prosecutor’s office. Eventually, they would be elected by popular vote. Much rides on the result.

Contrary to Mr Correa’s claims, Mr Moreno is not leading a counter-revolution or a right-wing government. He has kept several left-wingers and Correa allies in his cabinet. He has moved cautiously on the economy and in foreign policy: Ecuador remains, nominally at least, a member of ALBA, an alliance led by Venezuela and Cuba; Julian Assange, the fugitive founder of WikiLeaks, still lives in the Ecuadorean embassy in London. Things may change after the referendum. Mr Moreno faces a big fiscal deficit, low growth and the dollarised economy’s lack of competitiveness. To deal with them, he may need different policies and allies.

Ecuador shows that transitions from populist rule can potentially be constructive and consensual. In that, it is a counterpoint to Venezuela, where Nicolás Maduro took Hugo Chávez’s populist caudillo socialism and turned it into dictatorship. Perhaps nobody will be watching Ecuador more closely than Evo Morales, Bolivia’s president since 2006. Mr Morales is an autocratic socialist who both leads and is constrained by powerful social movements. His rule has been more similar to Mr Correa’s than to that of Venezuela’s chavistas. In 2016 he lost a referendum that would have abolished term limits. Now his supporters are seeking to achieve the same goal through the courts.

The longer populists remain in power, the more likely they are to mess up. But as Mr Moreno shows, a country can pull back from the brink.