Supporters of Spain's right-wing Popular Party were celebrating the election results into the night outside its headquarters in Madrid

Madrid (AFP) - With six months left until Spain’s general elections, Prime Minister Pedro Sanchez’s Socialists suffered a major setback in Sunday’s local and regional elections, initial results and media projections showed.

“We have won a clear victory and Spain has taken the first steps toward a new political era,” said the jubilant opposition leader Alberto Nunez Feijoo, head of the right-wing Popular Party (PP) in a victory speech early on Monday.

Widely seen as a dress rehearsal for the year-end legislative elections, Sunday’s polls saw the PP chalk up the largest number of local votes, official figures showed.

It also scored significant gains at a regional level, seizing six regions that had been under Socialist control, Spain’s public television station said.

But the PP will only be able to govern in those regions with the support of the far-right Vox, also a winner in Sunday’s polls – which poses a major headache for Feijoo.

Sunday's results will be a major blow for Socialist Prime Minister Pedro Sanchez

Vox, the third-largest party in parliament, is hoping to become an indispensable partner for the PP – both at a regional level and, ultimately, nationally.

Aware that the key to winning the general election is conquering the centre, Feijoo has sought to moderate the PP’s line while also keeping Vox at a distance.

A right-wing “tsunami” has swept through “every region in Spain”, said Javier Lamban, the Socialist leader of the northern Aragon region who lost his seat to the PP.

“We are facing an undeniable right-wing surge in Spain led by the PP and Vox,” agreed Miguel Angel Revilla, who also lost his seat as head of Cantabria’s regional government.

- ‘Not what we expected’ -

With almost all local ballots counted, the PP secured just over 7 million votes (31.52 percent), compared with nearly 6.3 million for the Socialists (28.11 percent).

Turnout was 63.89 percent, 1.3 percentage points lower than in the 2019 polls, official figures showed.

The figures are a major blow for Sanchez, whose Socialist party governs the eurozone’s fourth-largest economy in coalition with the far-left Podemos.

“This is not what we expected after these weeks of campaigning, obviously we need to reflect on this in the coming months,” admitted Socialist party spokeswoman Pilar Alegria.

Polls suggest Sanchez will lose the year-end election, which is seen as heralding a return of the right.

In another painful defeat, the Socialists also lost control of Seville – one of its strongholds and the largest city in the southern Andalusia region – to the PP.

They also failed in their attempt to take back Barcelona, Spain’s second city, which they had controlled between 1979 and 2011.

- Right-wing victory in Madrid -

Voters cast their ballots for local mayors as well as regional leaders in 12 of Spain's 17 regions

Polling stations closed at 8:00 pm (1800 GMT) after a day in which voters cast ballots for mayors in 8,131 municipalities, and leaders and assemblies in 12 of Spain’s 17 regions.

Of those 12 regions, 10 had been run by Socialists, either alone or in coalition.

In office since 2018, Sanchez has faced several obstacles: voter fatigue with his left-wing government, soaring inflation and falling purchasing power.

He has also struggled to contain the fallout from repeated crises between the Socialists and their hard-left coalition partner Podemos.

Early results showed Podemos suffering substantial losses.

Map of Spain showing the ruling party in each of the country's regions ahead of Sunday's elections

If Sanchez’s aim was to resist any advance of the right, Feijoo had two objectives: to secure the most local votes and to snatch as many regions as possible from the Socialists to show the tide of public opinion had turned against them.

In Madrid, the PP was celebrating a double win, with its hardline regional leader Isabel Diaz Ayuso winning an absolute majority meaning she will no longer have to rely on Vox for support.

And the capital’s PP mayor, Jose Luis Martinez-Almeida, was also reelected with an absolute majority.