At one point in his career, not too long ago, Pablo Iglesias had expected to become prime minister, part of a reshaping of Spanish politics that would empower the radical left.

But this week the leader of Spain’s Podemos announced the end of his political ambitions after coming fifth in a high-stakes election in Madrid, a contest in which he had planned to rally the left but instead united the right against himself.

“We have failed,” said the 42-year-old, who until last month served as a deputy prime minister in the national government, as he announced he was resigning all his remaining posts. “I am not contributing to an increase in support.”

It was a startling denouement for a man who had once hoped to lead a national government of the left — on the basis of inaccurate exit polls in the 2015 general election — but whose movement became weakened by internal feuds and failed to prosper in power.

Iglesias’s fall is more than a gamble that turned out to be one of the worst bets in Spain’s recent history; more even than an existential crisis for Podemos, which he has come to dominate in recent years, with the departure of his internal rivals.

It is also part of a political earthquake that has enfeebled Spain’s Socialist-led government, delivered a crushing victory to its foes on the right and strengthened regional leaders against the central administration.

The big victor of the Madrid vote is Isabel Díaz Ayuso, the regional leader who triggered the election and doubled the votes of her conservative People’s party, partly reversing the fragmentation of the Spanish right in recent years.

She emerged triumphant from a year of clashes with Pedro Sánchez, the Socialist prime minister, principally over her reluctance to enforce tighter coronavirus restrictions.

After securing her victory, she exulted: “They are not going to be able impose anything on us any more.” It was an indication that the result may accelerate a long-term trend in which the regions have gained power at the expense of the national government.

The Socialists are debilitated by their dismal showing in the race — from coming first in the previous election, in 2019, they fell to third place, losing more than a third of their vote — as well as the weakness of Podemos, their national coalition partner.

In Tuesday’s vote, both came behind More Madrid, a party formed by ex-Podemos leaders.

“The Socialists are partly being punished for their management of the pandemic and the economy [which last year contracted by 10.8 per cent],” said Pablo Simón, a prominent Spanish political scientist. “Sánchez is trusting that vaccinations, recovery and EU funds will improve his situation.”

In the meantime, the left is on the defensive. Díaz Ayuso managed not only to win back support from Ciudadanos, a failing centrist formation, but to increase the right’s overall share of the vote — to 58 per cent in Tuesday’s election from 51 per cent in 2019 — as she persuaded Socialists and people who had previously abstained to back her.

Both sides indicate that at least part of that success was due to Iglesias.

In his valedictory comments, Iglesias — a former adviser to the government of Venezuela whom Díaz Ayuso denounces as a disciple of the late Hugo Chávez — appeared to acknowledge that he had mobilised conservative and centrist votes against him more than he had energised the left. “I became a scapegoat,” he said.

By entering the campaign, the Podemos leader became a focus of attention, eclipsing the Socialists’ 72-year-old candidate Angel Gabilondo, who briefly and unconvincingly protested he would not form a government with Iglesias.

Eventually, the Socialists adopted an Iglesias-style strategy, campaigning against the threat of “fascism” — a reference to the likelihood that Díaz Ayuso would be propped up in power by the hard-right Vox. But Simón notes that Iglesias had the lowest poll ratings of the main candidates in the contest, an indication that voters were more concerned to keep him — and hence the left — out of office.

Now Iglesias has left Podemos to an uncertain future, although he has indicated his preference that he be succeeded as leader by Yolanda Díaz, Spain’s minister of labour, who has already taken his place as deputy prime minister.

She is a less divisive figure, despite being a card-carrying member of the Communist party. But daunting challenges remain for Podemos, which entered the national government as junior partner to the Socialists in January last year.

Like other smaller groupings to the left of the leading party, such as Georges Marchais’s Communists in François Mitterrand’s France of the early 1980s, or Germany’s Social Democrats during the grand coalitions of the last decade, its popularity has slid while in office.

“The junior partners in uneven coalitions often suffer a lot,” said Sandra León of the Carlos III University in Madrid, who noted that Podemos had failed to win representation to a number of regional parliaments, the ground zero of Spanish politics. “Podemos was built around the figure of Pablo Iglesias and this change of leadership clearly comes at a very difficult time for them.”

As Iglesias exits politics, the terrain could barely be more different to the election of 2015, when Podemos and Ciudadanos entered the national parliament with more than a third of the vote between them.

Now one of those forces — the centrist Ciudadanos — appears to be in terminal decline while Podemos is seeking to regain relevance as second fiddle to the Socialists, in the shade of a resurgent right.