BARCELONA, Spain — Spain's Socialists suffered a setback in regional elections in the country's south Sunday, the first electoral test for Prime Minister Pedro Sanchez's party since he took power in June.

The blow to the Socialists contrasted with the eruption of the anti-immigrant, extreme right Vox party, which claimed 12 seats in the 109-member regional parliament of Andalusia. Vox had not previously held any seats in any legislative body in Spain since its founding four years ago, and now it has the key to forming a government in Spain's most populated region.

"Now is the moment to say loud and clear who we are and that we have come to stay," Vox candidate told a crowd of supporters who chanted "Spain! Spain! Spain!"

Andalusia has been a Socialist bastion for 36 years, but the party could lose control of the government if parties on the right join forces to oust regional leader Susana Diaz, though that would require that they join forces with Vox.

With 99 percent of the votes counted, the Socialists won the election, but saw their support plummet to just 33 seats, compared to 47 in 2015. That left the Socialists far from the majority of 55 seats needed to govern, even if they can get the backing of the far-left party Adelante Andalucia, which took 17 seats.

"Despite winning the election it is a sad night for the Socialist Party," Diaz said. "There has been a real loss of ground for the Left. But the worst thing is that the extreme right, a phenomenon that has appeared in the rest of Europe, has arrived here."

The conservative Popular Party and center-right Citizens party held 47 seats between them. That gives them fewer than the Socialists and Adelante Andalucia, so they would need the votes of Vox to reach the absolute majority.

Diaz said she would call 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," she said.

Vox's platform includes a crackdown on immigration, a defense of Spain's unity against Catalonia secessionists, restricting abortion and rolling back domestic violence laws.

Two members of Vox shouted insults at Diaz when she submitted her ballot early Sunday in Seville. Vox said both people had been removed from their positions as voting monitors due to "inappropriate behavior."

Sanchez leads a minority government in Spain since he toppled former Prime Minister Mariano Rajoy, who lost a no-confidence vote. There is speculation Sanchez may call early elections if he cannot pass a national budget this year instead of serving out the legislative term that runs until 2020.