Ecuadoran President Lenín Moreno. (Daniel Tapia/Reuters)

RAFAEL CORREA, like Vladi­mir Putin, Hugo Chávez and other authoritarian rulers, found himself stymied by term limits. So in 2015, the Ecuadoran president persuaded his legislature to lift a ceiling of two presidential terms by promising not to run in 2017. His idea was to install a follower for four years and then return to power, as Mr. Putin once did. Then, on Sunday, came a much-deserved comeuppance: Ecuadoran voters, prompted by Mr. Correa’s own successor, voted overwhelmingly to restore a two-term presidential limit, thus blocking the planned second act. It was a victory for democracy not just in Ecuador but also in a region where numerous rulers have sought to entrench themselves in power.

Mr. Correa, who was first elected in 2007, embraced a somewhat milder version of Mr. Chávez’s left-wing populism. With the help of high prices for Ecuador’s oil exports, he reduced poverty while launching assaults on media freedom, private business and the courts. When oil prices fell, Mr. Correa followed Mr. Chávez in borrowing huge sums from China, promising future oil deliveries in exchange. Ecuador now owes Beijing the equivalent of three years of its production.

The caudillo clearly expected that his successor, Lenín Moreno, would follow his lead. Instead, to his credit, Mr. Moreno has moved to clean up the mess he inherited. He reached out to the media and businesses and let citizens know for the first time how much had been borrowed from China. When Mr. Correa’s vice president was implicated in a corruption scandal, Mr. Moreno made no attempt to shield him.

The new president is also looking for a way to end the government’s protection for Julian Assange, who has been holed up in the Ecuadoran Embassy in London since 2012. Mr. Moreno called the WikiLeaks founder “more than a nuisance” and warned him to stop meddling in the politics of other nations.

Predictably, Mr. Correa has called Mr. Moreno a traitor. In fact, Mr. Moreno is a moderate leftist who happens to believe in democracy. That has made him popular: His approval rating has soared, while Mr. Correa has been pelted with eggs during his recent public appearances.

Voters elsewhere in Latin America appear eager to push long-serving leaders out of power; the problem is that the caudillos aren’t listening. Bolivian President Evo Morales lost a referendum to remove his term limit, but then induced the supreme court he appointed to void it. Daniel Ortega of Nicaragua and Honduras’s Juan Orlando Hernández similarly manipulated their courts. After extracting permission to run for reelection, Mr. Hernández most likely stole Honduras’s election last November. But he began a new term of office last month with the support of the Trump administration.

The struggle over democracy in Latin America has been a seesaw battle in recent months. Venezuela has sunk deeper into dictatorship, and corruption scandals have destabilized Brazil and Peru. Ecuador, however, now appears to be joining Argentina in shaking off the destructive authoritarianism that spread across the region at the turn of the century. It’s a small but important step forward.