Spain was thrust into political uncertainty on Sunday after national elections left no party with enough support to form a government, most likely resulting in weeks of horse trading or potentially a new vote later this year.
Returns showed most votes were divided between the center right and center left. But neither the governing Socialist Party of Prime Minister Pedro Sánchez nor his conservative opponents won enough ballots to govern alone in the 350-seat Parliament.
While the conservatives came out ahead, the allies they might have partnered with to form a government in the hard-right Vox party saw their support crater, as Spaniards rejected extremist parties.
The outcome was an inconclusive election and a political muddle that has become familiar to Spaniards since their two-party system fractured nearly a decade ago. It seemed likely to leave Spain in political limbo at an important moment when it holds the rotating presidency of the European Council as it faces down the threat of Russian aggression in Ukraine.
The returns gave the conservative Popular Party an edge in seats over Mr. Sánchez’s Socialists. While slim, that number was expected to grow.
They had hoped to win an absolute majority and govern without Vox, which many of the party’s own officials consider anachronistic, anathema to Spain’s moderate values and dangerous.
As the votes came in, the Popular Party tried to put forward a positive face, saying that it had come in first place. This, said the party’s secretary general Concepción Gamarra, was “the only thing we know.”
But that wasn’t enough.
A political mess is not new to Spain. In 2016, the country spent 10 months in political limbo as it careened from election to election. Then Mr. Sánchez ousted the conservative prime minister and gained power in a parliamentary maneuver in 2018. More elections followed until Mr. Sánchez ultimately cobbled together a minority government with the far left and support in Parliament from small independence parties.
This time, Mr. Sánchez, a political survivalist of the first order, once again defied expectations, increasing his party’s seats in Parliament and gaining enough support with his left-wing allies for now to block the formation of a conservative government.
In the weeks leading up to the election, Mr. Sánchez and his left-wing allies raised fears about his conservative opponents’ willingness to partner with Vox, potentially making it the first hard-right party to join the government since the dictatorship of Gen. Francisco Franco nearly 50 years ago.
The prospect of Vox sharing power in government unnerved many Spaniards and sent ripples through the European Union and its remaining liberal strongholds, surprising many who had considered Spain inoculated against political extremes since the Franco regime ended in the 1970s.
Vox’s ascension, liberals argued, would amount to a troubling watershed for Spain and yet another sign of the rise of the right in Europe. Instead, Vox sank, and may have brought down the chances for the Popular Party to govern with it.
Mr. Sánchez, who has governed Spain for five years, will remain as leader of a caretaker government as the composition of a new government, or timing of new elections, is worked out.
Analysts have noted that Spain’s voters had grown tired of the extremes of the right and left and had sought to return to the center. A new election, they said, would continue that trend, and likely further marginalize Vox’s influence. The Popular Party hopes that it would take back their votes and grow large enough to govern on its own.
A progressive darling of the European Union, Mr. Sánchez presided over an economic rebound, but he alienated many voters by backtracking on promises and building alliances with political parties associated with the Catalan secessionists as well as former Basque terrorists who also once sought to split from Spain.
“I had a hard time deciding up to the last minute,” said Arnold Merino, 43, who voted for the conservative Popular Party. “People didn’t trust him.”
Mr. Sánchez called the elections early — they had been scheduled at the end of the year — after a bruising in local and regional elections in May.
In the closing days of the race, the Socialists and the far-left umbrella group, Sumar, projected optimism about the possibility of turning things around as polls showed them trailing. Billboards around Spain showed Mr. Sánchez looking youthful and suave under a sign for “Forward” next to black-and-white pictures of the conservative leaders reading, “Backward.”
The Popular Party ran less on policy proposals than against Mr. Sánchez. Both the conservatives and their hard-right allies ran a campaign sharply critical of Mr. Sánchez, or a style of governing they called “Sanchismo,” saying he could not be trusted as he broke his word to voters, made alliances with the far left and cut electorally advantageous deals that put his own political survival ahead of the national interest.
Even so, Spain seemed in recent years to be a bright spot for liberals. Mr. Sánchez kept inflation low, reduced tensions with separatists in Catalonia and increased the economic growth rate, pensions and the minimum wage.
But the alliance between Mr. Sánchez and deeply polarizing separatists and far-left forces fueled resentment among many voters. The entire campaign, which included Mr. Sánchez and his far-left ally warning against the extremism of Vox, turned on the bad company of the main parties’ allies.
And yet, for all the talk about extremism, results showed that Spanish voters, many of whom were haunted by the dictatorship and the decades of terrorism spawned by related territorial disputes, turned to the center.
The Vox party, widely seen as a clear descendant of Franco’s dictatorship, looked on track to lose more than 20 seats. It ran on opposition to abortion and L.G.B.T.Q. rights and European Union meddling in Spanish affairs, and is staunchly anti-immigrant.
“I think people want to go back to bipartisanship, because it provides stability,” said Mr. Merino. “With the Popular Party, you know what you are getting.”
The leader of Vox, Santiago Abascal, split from the Popular Party amid a slush-fund scandal in 2013. Vox started with stunts like draping Gibraltar, the southern tip of the country controlled by Britain since 1713, with a Spanish flag.
It filmed alternate realities in which Muslims imposed Shariah law in southern Spain and turned the Cathedral of Cordoba back into a mosque. In another video, scored to the soundtrack of Lord of the Rings, a cultural touchstone for Europe’s new hard right, Mr. Abascal leads a posse of men on horseback to reconquer Europe.
“It’s very allegoric. But it’s also beautiful,” said Aurora Rodil, a Vox deputy mayor of the southern town of Elche who already governed with the Popular Party mayor. “There’s so much to be reconquered in Spain.”
But Sunday’s vote showed that they had been beaten back.
“Spain is really balanced,” said Ramon Campoy, 35, as he took a break from work on Friday in Barcelona, standing under the L.G.B.T.Q. flag in a square graced by an equestrian statue of Ramon Berenguer III, the crowned 11th-century ruler of Catalonia.
Mr. Campoy added, “I think the country is really in the center.”