There was one major beneficiary of Sunday’s inconclusive election in Spain, but it was not Pedro Sánchez, the Socialist prime minister. Mr Sánchez hoped a fourth poll in as many years might finally deliver him the numbers to break a debilitating deadlock in parliament. Instead, the Socialist Workers’ party emerged as the largest party once again, but lost three seats and must enter yet more tortured negotiations with other parties in order to find a way to govern.

The real celebrations of Sunday evening took place at the headquarters of Vox, a far-right nationalist party. Vox increased its share of the vote to 15.1%, won 52 seats and became the third-biggest party in Spain. Its leader, Santiago Abascal, told cheering supporters that the results meant “a patriotic alternative has been consolidated in Spain”, and called for “the restoration of national unity with the application of direct rule in Catalonia”.

Until very recently, Spain appeared immune to the rightwing populism that gained ground in other European countries following the 2008 crash. But the rapid rise of Vox is testimony to the way in which events in Catalonia have contributed to an alarming rightwards shift in Spanish politics. The election campaign took place against a backdrop of sometimes violent demonstrations in Barcelona, where huge numbers protested at long prison sentences handed to pro-independence politicians, who were found guilty of sedition by Spain’s supreme court.

Play Video ‘Make Spain great again’: does Melilla really need a Trump-style wall? – video

The polarisation of opinion over the crisis has licensed an ugly re-emergence of authoritarian strains of Spanish nationalism, which are seeping into the political mainstream. When Vox proposed the banning of any political party that threatened “the unity of the nation”, the centre-right People’s party (PP) and the liberal Citizens movement scrambled to endorse the symbolic move. Much of the rest of Vox’s rhetoric draws from a familiar populist right playbook: lurid scaremongering in relation to immigrants, Islamophobia and condemnations of “gender ideology” allegedly imposed on society by a progressive dictatorship.

On the eve of the election, Mr Sánchez highlighted the difficulties Spain faced as a result of political fragmentation, the Catalan crisis and the growing profile of the far right. The election results have vindicated those fears and left him with a complicated set of options. The PP’s leader, Pablo Casado, has said he will wait to see the prime minister’s next move. A grand coalition would at least give Spain some political stability, but has been ruled out by Mr Sánchez and would almost certainly have meant a tougher line on Catalonia, meaning further opportunities for Vox to exploit any Catalan backlash.

Pablo Iglesias, the leader of Podemos, has suggested a renewed willingness to form a leftwing coalition with the PS, but the combined numbers of both parties would still not add up to a majority. It all looks very messy. But congratulatory messages for Vox from Marine Le Pen, Matteo Salvini and Geert Wilders should now concentrate minds. The cordon sanitaire protecting Spanish politics from the far right has been well and truly breached. For the other parties, the time for prevarication is over.