(Bloomberg) -- Spanish Prime Minister Pedro Sanchez said he will dissolve parliament and call a snap election for July 23 after his Socialist party suffered heavy losses in regional and local elections on Sunday. 

Sanchez’s decision to bring forward a general election not expected until December looks like a ploy to wrest the initiative back from his conservative opponents after seeing his support hit by near-record food inflation and a botched attempt to tighten sentencing for rapists. The timing of the vote will ramp up the pressure on Sanchez’s leftist coalition partners who have been struggling to resolve a dispute over whether they can unite under a single banner. 

Alberto Nunez Feijoo’s People’s Party, joined in some places by the far-right Vox, is set to control eight of the 12 regions that were up for grabs in the weekend ballot, including the bellwethers Madrid and Valencia. Historically, the party that comes on top in the local election tends to win the national vote.

Speaking on the steps of his official residence in Madrid, Sanchez said that Spain needs “clarification” from voters of where the government should be headed and who should lead it. “It’s best for the Spanish people to have their say and to decide without delay on the political direction of the country,” he said. 

Spanish equities erased earlier gains to trade 0.2% lower after the announcement. The country’s Ibex-35 had advanced as much as 0.8%. Spain’s 10-year government bonds extended gains, sending the yield 10 basis point lower to 3.50% at 1:33 p.m.

Sunday’s result suggests that the PP will start as favorite to win the ballot in July but the complex dynamics of coalition building in Spain mean it may be difficult for him to form a majority. 

“The left did very poorly and that means the prospect of another left-wing coalition are a lot slimmer now,” Federico Santi, a senior analyst with Eurasia Group, said in an interview. 

Still, the PP will need to rely on support from the far-right group Vox in order to govern in many regions and cutting those deals may make it practically impossible to win support from the Basque and Catalan nationalist who have traditionally helped form majorities in the national parliament. The nativist group Vox emerged as a new political force after Catalan nationalists held an illegal referendum on separating from the rest of Spain in 2017.

The PP on Sunday won 31.5% of municipal votes nationwide, up from 22% in 2019, while the Socialists fell to 28%. Vox more than doubled its votes to 7%. Feijoo has promised to be more business-friendly than Sanchez, who has had a contentious relationship with corporate Spain.

“We have clearly won, and taken our first step to usher in a new political cycle in Spain,” Feijoo told hundreds of supporters outside the party headquarter in Madrid late Sunday.

The Sanchez government had riled up executives and wealthier Spaniards by imposing windfall taxes on energy companies and banks as well as a wealth tax to help offset rising costs. Spain has also received more than 50% of the €69.6 billion ($74.6 billion) in grants allocated to it from the European Union’s pandemic-era recovery fund.

In government, voters weren’t convinced by Sanchez’s stewardship of the economy, despite Spain outperforming most of its euro-area peers during the first part of the year. Sanchez pumped billions of euros into the economy to shield households and businesses from rising costs amid a surge in inflation.

“Spain is about to emerge from a period of crisis stemming from the Covid-19 emergency and also the war in Ukraine,” the prime minister said on Monday. “We are on a clear path of growth, job creation and social cohesion.”

The Bank of Spain said earlier this month that it would likely boost its 2023 outlook for expansion above 2%. The resilient economy led the budget ministry to predict that Spain would be able to cut its deficit to 3% of economic output in 2024, a year ahead of target.

Sanchez rose to power five years ago after stitching together an alliance of leftist and regional parties to win a no-confidence vote against his conservative predecessor, Mariano Rajoy. That was just one of a series of high-stakes gambits that have marked a political career that seemed over when he was ousted from the Socialist leadership in 2016 following a rebellion of some of his closest allies. Sanchez won the subsequent leadership contest against the party establishment’s nominee by touring the country to reach out to grassroots members. 

Sanchez’s coalition partner in the national government, the left-wing group Unidas Podemos, was also battered in Sunday’s election, losing representatives and preventing the socialist’s from retaining key strongholds. The party’s leaders, who’ve also seen their support plummet in national polls, are tussling with left-wing Deputy Prime Minister Yolanda Diaz from a rival group over who should lead their movement going into a general election. 

“With the political prospects worsening, Sanchez is cutting his loses before the conservatives can take over the regional governments and oppose him in unison,” Ramon Mateo, director of policy of the BeBartlet consultancy firm in Madrid, said in an interview. “He’s going on the offensive — for him it’s now or never.” 

(Updates markets in the fifth paragraph and adds context throughout)

©2023 Bloomberg L.P.