Supporters of former President Evo Morales stand Sunday next to a burning tire at a blockade along a road leading to the state-own Senkata gas filing plant in El Alto, Bolivia. Bolivia's political crisis turned deadly after security forces opened fire on supporters of Morales in Sacaba on Friday, killing multiple people and injuring dozens. Credit: Natacha Pisarenko | AP

“Democracy is in danger in Bolivia as the result of legitimate pressures from the poor. We cannot generate economic growth and well-being for a few and then expect that the large majorities that are excluded will watch silently and patiently.” A recent president of Bolivia said that, but it wasn’t Evo Morales (who has just quit).

It was Carlos Mesa, the man whom Morales tried to cheat out of the presidency in last month’s election. Mesa said it in 2005, the last time he was president, just before he quit and Morales won a landslide victory in the election triggered by his resignation.

Most outside commentators used to stick to a simple script when talking about Bolivia. Morales was the good guy, because he was the country’s first indigenous president (he grew up speaking Aymara, and only learned Spanish as a young adult), and because he looked like and seemed to care about the poor majority of Bolivians.

Whereas Mesa belongs to the privileged white minority (15 percent of the population) who have always controlled both the politics and the wealth, so he must be the bad guy. But his face doesn’t fit the frame: he is an historian and television journalist, and he resigned from the presidency in 2005 after trying and failing to nationalize the country’s gas industry.

Morales took his place, and he did better. Morales nationalized not only oil and gas, but the tin and zinc mines and key utilities as well. He got away with it, whereas Mesa couldn’t because he paid out good compensation to the owners — and he could do that because Bolivia was riding a commodities boom that tripled the country’s GDP in 15 years.

Morales’ mistake was to believe that he was the indispensable man. He clung to office too long, and now he is toast. He will retain enough of a following to be a permanent political nuisance, but he has embarrassed his country and he’s unlikely ever to hold high office again.

Under the new constitution of 2009, promulgated by Morales himself, a Bolivian president is entitled to only two five-year terms. But as he got closer to the 2019 deadline, Morales changed his mind, and in 2016, he held a referendum that proposed to allow the president any number of terms. He lost.

So Morales went to the Supreme Electoral Tribunal, which is dominated by his own party. Unsurprisingly, the tribunal agreed that the two-term constitutional limit violated his “human rights” — so there he was last month, seeking a fourth term as president in a race with eight other candidates.

Everybody knew that Morales would lead and Mesa would be the runner-up in the first round of voting. Many suspected that Mesa would pick up more votes and overtake Morales in the second round — so his advisers decided that he had to win in the first round. He could do that only if he were ahead of Mesa by at least 10 percent of the votes cast.

On Oct. 20, the “fast count” of the national vote went smoothly until 84 percent of all the votes had been counted — at which point it became clear that Morales was not going to have a big enough lead over Mesa. So suddenly the counting stopped, and did not resume for 24 hours. It then showed Morales with a 10.1 percent lead over Mesa, so no second round was needed. All hail Morales’ fourth term!

But the vote-rigging was just too blatant, and for almost three weeks protesters took to the streets. By the end, even the police refused to defend Morales.

When the election monitors from the Organization of American States delivered their verdict on Nov. 10, saying that there were “serious security flaws” in the computer systems and “clear manipulation” of the count, Morales resigned. The election results were canceled, and it’s pretty clear that he will not be a candidate when the re-run happens.

And here’s a take-away for everybody in politics: if you are going to rig the vote, do it from the start. Don’t wait until the count shows that your candidate is not doing well, and only then intervene to fix it. Amateurs!

Gwynne Dyer’s new book is “Growing Pains: The Future of Democracy (and Work).”