MADRID (AP) — A regional election in Spain saw a surge of support for a far-right party and dealt a major setback to the ruling Socialists, prompting the prime minister on Monday to vow to defend democracy from fear.

The anti-migrant, anti-feminist and euroskeptic Vox party won 12 seats Sunday in the 109-member parliament of Andalusia, Spain's most populated region and a bastion of the Socialists for the past 36 years.

The four-year-old Vox party, which had not previously held any seats in Spain, could now be a kingmaker and oust the Socialists from Andalusia's regional government if they strike a deal with conservatives and the center-right to assemble a 59-seat majority.

Those leaders on Monday began talks to form a regional government, which both parties said would include contacts with Vox.

The surprising win — the most favorable polls ahead of the election predicted Vox would win about five seats — also launched the party's strategy to make a dent in national politics and the European elections next year. It's also a blow to those who had felt that sour memories of Spain's 20th-century dictatorship and a consensus over the European Union's benefits had inoculated the country from a global wave of rising populism.

French far-right leader Marine Le Pen was one of the first to celebrate Vox's success, congratulating the party's national leader, Santiago Abascal, in a tweet for what she said was "a very significant result for a young and dynamic movement."

In a sharp contrast, Spain's Socialist prime minister, Pedro Sanchez, tweeted Monday that "my government will continue working on a regenerating and pro-European project for Spain." He said the result will "strengthen our pledge to defend the Constitution and Democracy against fear."

The Socialists saw their support plummet to just 33 seats, compared to 47 in 2015 and far from the majority of 55 needed to govern even if they could get the backing of Adelante Andalucia, the local brand of the anti-establishment Podemos party, which took 17 seats.

The conservative Popular Party came second with 26 seats — down seven from previously — and the center-right Citizens party more than doubled its presence in the regional assembly, capturing 21 seats.

Still, analysts said that having Spain's right-wing side themselves with the far-right could backfire, especially with local, other regional and European elections next year and a possible general election that could come any time before 2020.

That's the limit of the legislative term for Sanchez, who toppled former conservative Prime Minister Mariano Rajoy in June with a no-confidence vote. Sanchez now leads Spain's weakest minority government in four decades of democracy and there is increasing speculation that he could be calling an early election.

The acting regional president in Andalusia, Susana Diaz, blamed the Socialists' loss of support on the high rate of abstention, which has been interpreted as punishment by traditional center-left voters to the corruption scandals marring her party.

"We have understood the message and we take note," said Diaz, who also called on other parties to "build a firewall against the extreme right in Spain."

"Each party must decide if they are against the extreme right or if they will rely on their support to enter into government," Diaz said.

Abascal, a 42-year-old scion of a family targeted by the separatist militant group ETA in his native Basque region, celebrated Vox's victory saying the support came from those disgruntled and neglected in Andalusia who wanted to hear a party speak about "issues that they felt and no other party represented."

He also rejected the criticism from mainstream parties and media. "You haven't understood anything," Abascal told them during a news conference. "Every time you insult us, you are insulting the millions of Spanish people who listen to us and identify with our message."

A 100-issue Vox manifesto calls on building a Spanish nation where its 17 autonomous regions have limited powers, starting with education and health policies, and wants Catalonia to lose its self-government after last year's attempt to split from Spain.

The party also advocates outlawing separatist parties, lowering taxes, reforming laws on domestic violence, restricting abortion and closing doors to undocumented migrants.

Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.