Peru, the investor mantra went, was a gravity-defying emerging market: its dismal politics didn’t matter because its economy was reliably strong. As the country prepares to choose its fifth president in five years on Sunday in a run-off between two divisive and ill-qualified candidates, with the world’s worst per capita death toll from coronavirus and one of the biggest emerging market recessions last year, politics has moved centre stage.

Leading the polls is Pedro Castillo, a teacher and union activist from the Andean highlands with no experience of elected office. He has panicked Peru’s elite and delighted its rural masses by running on a hard-left populist platform. The ruling classes’ alarm is heightened by the alternative: Keiko Fujimori, the unpopular daughter of a jailed former authoritarian president, herself under investigation for corruption.

There are important lessons for other poor countries in the downfall of one widely described as a success story as recently as five years ago. The world’s second largest copper producer, Peru rode the commodities boom and its immediate aftermath with aplomb. In the decade leading up to the pandemic, it combined Latin America’s second highest annual growth rate of 5.9 per cent with low inflation and modest debt.

The microeconomics were less impressive. As Peru grew wealthier, the new middle classes abandoned poor-quality health and education services for private alternatives. Local oligopolies stifled competition. Many jobs created were low wage and informal. A bungled decentralisation farmed out key services to regional authorities ill-equipped to handle them.

Peru’s toxic politics contaminated the country’s institutions. Successive corruption scandals snared all the country’s living former presidents and much of its congress. The party system collapsed, leaving a splintered parliament full of tarnished one-term legislators with little incentive to consider the long term. Fear of investigation by ever more zealous prosecutors paralysed spending on key public works projects.

When coronavirus hit the country with full force last year, the government’s initial response seemed promising. It combined a long, strict lockdown with a big social assistance package worth 20 per cent of national income. The results were disastrous. The economy was crippled, deaths soared and poverty worsened.

What emerged through the chaos was a picture of a state chronically unable to deliver. The health system proved hopelessly inadequate. Enforcement of the lockdown was patchy. Those who toiled in the informal economy had no choice but to continue working. Much of the welfare aid failed to reach its destination. Budgets were not fully spent. The government was slow to secure vaccines and became embroiled in a scandal after revelations that top officials were secretly inoculated first.

Many of Peru’s failings are shared by its neighbours. Widespread and sometimes violent protests have shaken Chile, Colombia and Ecuador in the past two years and politics in these countries has become more poisonous.

The lessons post pandemic should include evaluating emerging markets on a much broader range of indicators than economic fundamentals. These should include performance in health, education and infrastructure and reflect outcomes delivered, rather than budgets allocated. Neither the best-run central bank nor the most technocratic finance ministry count for much if the rest of the state is deficient. Long-term investors ignore politics at their peril.