IN RECENT months the fluctuation of the Mexican peso against the dollar has resembled an electrocardiogram during a panic attack. The currency fell some 15% after the victory of Donald Trump, who promised to scrap the North American Free-Trade Agreement (NAFTA) linking Mexico, the United States and Canada. The peso has since recovered, on mounting hopes that Mr Trump’s administration will recognise the mutual benefit in NAFTA. But there is another nightmare troubling the currency markets: the notion that Andrés Manuel López Obrador, a left-wing populist who in some ways resembles Mr Trump, will win a presidential election a year from now.

After wobbling in May when polls suggested that Mr López Obrador’s candidate might win the governorship of the State of Mexico, the biggest of four states to hold elections on June 4th, the peso gained 2.5% when preliminary results signalled a narrow victory for the ruling Institutional Revolutionary Party (PRI) of President Enrique Peña Nieto. That relief may be misplaced. Though final results may take weeks, overall the outcome gave Mr López Obrador, whom Mexicans refer to as AMLO, cause for cheer.

In the State of Mexico, which contains 13% of the national electorate and was once governed by Mr Peña, AMLO’s candidate, Delfina Gómez, a teacher, gained 31% of the vote. The PRI won, with 34%, in a state it had never lost, but its vote was down by 28 percentage points compared with the last election in 2011. It clung on, according to its opponents and some analysts, only by large-scale vote-buying.

Mr López Obrador has thus reminded Mexicans that he remains a uniquely potent challenger. He has acquired a loyal following among poorer voters, especially in the centre and south, by railing against a corrupt political system and a chronically mediocre economy, and by promising to review NAFTA and reverse the globalising economic policies Mexico has adopted in the past 30 years.

But he also gets in his own way. His messianism and unsubstantiated cries of fraud in past elections alienated former sympathisers in the middle class. After narrowly losing two presidential elections, he split from the centre-left Party of the Democratic Revolution (PRD) because of its support for Mr Peña’s modernising reforms. In 2014 he set up the Movement for National Regeneration (Morena), whose sole purpose is to promote its leader.

AMLO heads most opinion polls for the presidential election. That is largely because of the flaws of his rivals. On the one hand, Mr Peña is widely reviled, mainly because of his failure to tackle violent crime and rampant corruption. Defeat in the State of Mexico would have been catastrophic for him; narrow victory there (and possibly in Coahuila, a smaller state) is not enough for him to impose his choice of candidate on his party.

On the other hand, the appeal of the conservative National Action Party was diminished by the disappointing presidencies of Vicente Fox and Felipe Calderón between 2000 and 2012. Worse, the party is split between the presidential ambitions of Ricardo Anaya, its young general secretary, and Margarita Zavala, Mr Calderón’s wife.

Nevertheless, it is far from inevitable that Mr López Obrador will win next year. What was once a three-party system has fragmented. The victor will be the candidate who is best at forging alliances. On that, AMLO has a mixed record. In the State of Mexico, had he struck a deal with his former companions in the PRD (whose candidate won 18%), Morena would have won with ease. But Mr López Obrador “wants subordination, not union”, and is seeking “employees, not allies”, a PRD leader complained.

Mexico’s constitution does not allow for a run-off election. (Many political commentators believe that should be changed, but it probably cannot be in time for next year’s contest.) In 2012 Mr Peña won with just 38% of the vote. His successor may need less than 30%. In the absence of a run-off, Mexicans vote tactically. Referring to the State of Mexico, Enrique Ochoa, the PRI’s president, thanked “those who voted for us although we weren’t their first choice”. He went on: “Together we halted the advance of authoritarian populism” and “we will do so again successfully in 2018.”

Whether the PRI can be the standard-bearer of such an anti-AMLO coalition next year is questionable. But someone can be. A successful candidate will need not just to argue that “Mexico does not deserve to be Venezuela,” as Mr Ochoa put it, but also to present a vision of positive democratic change. Mexico still has a few months to find such a person.