A COUPLE of years ago Julio Guzmán decided he wanted to run for president of Peru. On the face of things, that was implausible. He had never been a candidate for political office before. His experience of government was confined to two short stints as a deputy minister in the administration of the current president, Ollanta Humala. An economist, he had spent much of his working life abroad as an official at the Inter-American Development Bank.

A small and dormant political party called Everyone for Peru (TPP in Spanish) agreed to field him as its candidate. For months he made no perceptible impact on the campaign for the election due on April 10th. But by street leafleting and through social media he gained support, especially among young people. This year he has surged in the opinion polls to 17%, behind only the long-standing front-runner, Keiko Fujimori (35%). In a run-off ballot, which would take place in June, he is the only candidate who might come close to beating Ms Fujimori.

So it matters greatly that on February 16th the electoral court in effect stalled Mr Guzmán’s campaign. By three votes to two, it refused his appeal against an administrative ruling that TPP had broken its own statutes in the way that it organised the meeting in October that chose him as its candidate. Confusingly, the court’s decision does not in itself annul his candidacy: a separate tribunal must now decide on that. But in practice the court has disabled it. Unless the court quickly reverses itself, weeks of legal argument may lie ahead.

“It’s the political system [uniting] against a new option,” declared Mr Guzmán, though he insisted he would carry on campaigning. It is part of his pitch that he represents a middle-class insurgency against an entrenched reactionary “establishment”, a word he uses a lot.

The court’s majority deployed pettifogging legalism, giving more value to secondary regulation than to Mr Guzmán’s constitutional right to run and the right of the people to choose whomever they please—the essence of democracy. Even in narrow terms, the decision is questionable: the dissenting two pointed out that TPP later held a congress which endorsed the choice of Mr Guzmán and that no party member had complained.

The underlying problem is that Peru is a democracy in which hardly any of the 25 registered political parties is worthy of the name. “They are shells,” says Fernando Tuesta, a political scientist and former electoral official. “No party conducts an internal election as it should be done.” César Acuña, the owner of three private universities who is accused of serial plagiarism and vote-buying (which he denies), remains in the race.

The absence of parties is both a cause and an effect of the general contempt in which Peruvians hold their politicians. It injects unpredictability into elections and explains why Mr Guzmán could come from nowhere. Aged 45, he is slim, short, articulate and relaxed. He presents himself as a post-ideological candidate situated firmly in the political centre. “What’s demanded today is accountability, authenticity and effectiveness,” he told Bello earlier this month.

He reeled off his priorities for government: pre-school education, promoting innovation and a higher-tech economy, reform of the state and so on. He stresses policies to help the middle class. Many of these are sensible but not especially novel, as he admits. He gives the sense of making some things up as he goes along, and sometimes contradicts himself. That hasn’t halted his surge. For it is Mr Guzmán himself, as a fresh face and political outsider, who provides the novelty that Peruvians crave.

Peru has fared well for most of the past 15 years, as faster economic growth has slashed poverty and paid for social progress. But growth has slowed, crime has risen and corruption scandals have proliferated. Peruvian democracy has been held together not so much by parties as by economic success and a consensus that the government should be run by technocrats (such as Mr Guzmán). But are these still enough?

It is ironic that the only semi-serious party is that of Ms Fujimori, whose father spurned political parties when he ruled the country as an autocrat in the 1990s. To her credit, she has been firmer than other rivals in defending Mr Guzmán’s right to run. In the short term, she may be the main beneficiary if he is disqualified: she might then win without a run-off. But it is in no one’s interest that the electoral court has disrupted Peru’s election and potentially undermined the legitimacy of its eventual winner.