A decisive socialist win in Spain’s election on Sunday may be seen in Europe as evidence of a gathering centre-left recovery – but it also underlines the dangers to moderate conservatives of courting the far right.

Pedro Sánchez’s Socialist party (PSOE) won 123 seats and 29% of the vote in Sunday’s election, well up on the 85 seats and 23% they got in 2016. The conservative People’s party (PP) lost half its vote share and half its MPs, finishing second with 66 seats.

In an increasingly fragmented landscape – Spain’s two mainstream parties could once expect 80% of the vote between them – the centre-right Ciudadanos (Citizens) won 57 seats, the anti-austerity Unidas Podemos (United We Can) and its allies 42, and the far-right Vox 24.

The outcome vindicated Sánchez’s modest but determined campaign, demonstrating that centre-left parties can still win European elections by pursuing left-of-centre, socially liberal policies and attacking the far right.

It also cements what is starting to look like something of an upturn in the fortunes of the continent’s social democratic parties after a generally catastrophic few years of austerity-ravaged fallout from the 2008 financial crisis.

Sweden’s Social Democrats managed to remain the country’s largest party last year and – perhaps a greater challenge – to form a government afterwards, while the centre-left came top in Finnish elections this month for the first time in 20 years.

Social democrats are currently leading in the polls in Denmark, which is due a general election this summer, Portugal’s socialists look set for re-election later this year, and even Italy’s Democratic party is starting to climb back up in the polls.

The left may, perhaps, take heart from the popularity of Sánchez’s policies. Since becoming prime minister last year after his predecessor, the conservative Mariano Rajoy, lost a no-confidence vote, the Socialist leader has raised Spain’s minimum wage by 22% and given the country’s 2.5 million public sector workers a 2.5% pay rise.

But Sanchez also hit back at the far right, using the threat of the nationalist, anti-immigration, reactionary Vox – the first far-right group to win more than one seat in parliament since Spain’s return to democracy after General Franco’s death – to mobilise left-leaning voters. A government backed by the far right risked “setting the country back 40 years”, he said.

Equally significant in the socialists’ victory was the dramatic collapse of the centre-right PP, which under Pablo Casado’s leadership has increasingly adopted a far-right, socially conservative stance on issues ranging from tax, abortion and immigration to Catalan independence and “political correctness”.

It proved a disastrous strategy, with radical PP voters heading either for Vox (on the grounds, presumably, that the original was preferable to the imitation) or Ciudadanos, and leftwing voters deciding it was more important than ever to turn up and cast their ballot.

The PP’s sudden implosion, and the splitting of Spain’s broad right into three separate factions, reflects a clear European trend: centre-right parties that try to outflank the populist far right by adopting ultra-conservative, nation-first policies and rhetoric are punished at the polls – and not just by the far right.

Most recently the Netherlands’ four-party ruling coalition, led by the prime minister Mark Rutte’s conservative VVD party, lost out in elections to the upper house to both the new far-right party Forum for Democracy (FvD) and Green Left, and will now have to seek alliances with the opposition to pass legislation.

Most spectacularly, the vote for the previously all-conquering CSU, the Bavarian sister party of Angela Merkel’s centre-right CDU, collapsed in October as a hardline campaign aimed at countering the far-right Alternative für Deutschland(AfD) failed to win back rightwing voters and offended its more moderate supporters.

Like other centre-left leaders who, in an increasingly polarised and fractured European politics, have fared better than they may have expected in recent months, Sánchez will not find it easy to build or retain a majority in parliament.

But if the collapse of the EU’s traditional social democratic parties was long expected to be one of the major stories of next month’s European parliamentary elections, it is now looking rather as if the mainstream centre-right may be in even greater trouble.