ALTHOUGH he has more than three years left of his current term as Bolivia’s president, Evo Morales called a referendum for February 21st to change the constitution to allow him to run for a fourth term in 2020. This excess of forward planning in a region accustomed to last-minute improvisation smacked of nervousness about tougher times ahead in Bolivia. It backfired: with nearly all of the votes counted, the “No” vote stood at 51.3%. Albeit narrowly, Bolivians have inflicted on Mr Morales his first serious electoral defeat since he was elected in 2005.

This setback for Bolivia’s president will echo around South America. Despite his support for Hugo Chávez’s “Bolivarian revolution” in Venezuela and his unremitting anti-American rhetoric, Mr Morales is the most fiscally responsible of the left-wing leaders in the region. He is also the most popular and was the strongest of them politically, thanks to his ethnicity (he is of indigenous Aymara descent), his stress on social inclusion and recent pragmatic overtures to the private sector. Buoyed by natural gas and mining exports, the economy has grown at around 5% a year for a decade. Now it is slowing. Mr Morales’s government has been rocked by corruption scandals. “Perhaps our support is not what it was,” he admitted to El País, a Spanish newspaper, on the eve of the referendum.

That goes a fortiori for the left elsewhere in the region. It has suffered electoral defeats in Argentina and Venezuela. In Ecuador Rafael Correa has said he will not run again next year.

In Brazil the government of Dilma Rousseff is not certain to survive to the end of its term in 2018. This week João Santana, her campaign guru, was arrested on suspicion that he was paid with money from bribes. If substantiated that could prompt the electoral court to call a fresh election. In Chile, Michelle Bachelet, a once-adored president, languishes in the opinion polls.

Three things are behind the left’s fall from grace. One is the end of the commodity boom. The governments in Venezuela (especially), Brazil and Argentina made no effort to save the windfall gains from the boom. Impelled by a refusal to risk unpopularity and electoral defeat, they carried on spending even as commodity prices began to fall. That is an old mistake. As Mr Morales says, he advised Chávez that “you can’t carry on subsidising so much”. He added that “to maintain the ideology, you have to guarantee [that people have] food”. The second factor is corruption, especially in Venezuela and Brazil. Of the left-wing governments only Uruguay’s is unscathed by scandal.

Third, after a decade or more of left-wing dominance voters want fresh faces and the alternation of power.

All this means that Mauricio Macri’s victory in Argentina’s presidential election last November may presage further electoral success for the centre-right. After a decade in which much of Latin America looked to China, Barack Obama will be widely applauded when he visits Argentina and Cuba next month.

But governing has got harder for everyone in the region. True, the difference between well-managed countries, like Colombia and Peru, and those that made mistakes is significant: rates of economic growth of 2-3% and inflation of 2-7% feel much better than recessions and inflation of over 10%. But the days of limitless fiscal revenue and easy popularity are over. And corruption is not a monopoly of the left: witness Otto Pérez, the conservative president of Guatemala, who was toppled by a citizens’ movement last year and is on trial for embezzlement.

Tackling corruption requires the patient work of building the rule of law. And boosting economic growth demands the hard grind of improving productivity and competitiveness, through investing more in infrastructure, better education, more efficient labour markets and so on. Above all, these tasks need leaner but stronger and more effective states.

How to get there? “The most important economic problem today is political: that the various spheres of society reach agreement to put much more stress on productive transformation,” counsels Enrique García of CAF, a development bank.

That is something Latin America has been poor at. In the past the right ignored inequality and poverty. The left can claim credit for placing these issues at the heart of the political agenda, where they belong. But the commodity boom also served to give old ideologies a new lease of life. Too many of the left’s leaders ruled through the politics of confrontation rather than consensus-building. The region is now in for a period of shorter, more volatile political cycles in which the winners will be those who succeed in marshalling support for difficult but overdue changes.