(Bloomberg) -- Prime Minister Pedro Sanchez is betting that he can exploit the quirks of Spain’s fractured political landscape to cling on to power after his Socialist party suffered a crushing defeat in Sunday’s regional elections. 

Sanchez, 51, surprised his adversaries on Monday by dissolving parliament and triggering a snap general election within hours of learning the full extent of his losses in the previous day’s ballots. Spanish parties will have less than two months to prepare and campaign for the July 23 election, which had been expected to be held in December. 

Read More: A 25,000-Mile Road Trip Set Sanchez on Path to Power in Spain

It might seem counterintuitive to call an election when the governing party’s fortunes are at a low ebb, and the Socialists have been polling consistently behind the center-right People’s Party for months. But Sanchez has proved himself to be the master of the complex coalition politics ushered in by the collapse of the old two party system over the past decade. 

In order for PP leader Alberto Nunez Feijoo to oust Sanchez in the upcoming vote, he needs to win an absolute majority of 176 seats in parliament or slightly less if he is able to get other parties to abstain. Some recent polls suggest that Feijoo and potential ally, far-right party Vox, might just win enough seats, but it will likely be a tight race. If he fails to secure a majority with Vox, the PP will likely struggle to attract more support from the patchwork of regional parties that despise Vox’s Spanish nationalism. 

Political Risks

An extended standoff might be bad for Spain, leaving the country without a proper government potentially for months on end, but Sanchez has shown in the past that he’s prepared to withstand the pressure that brings if it suits his political interests. 

Sanchez has built an unlikely political career by taking just such bets. 

“I don’t remember any other premier who has taken so many risks, but Sanchez has some control over those risks,” said Irene Delgado, a professor of political science at UNED University in Madrid. “There is a clear strategy to capitalize on this urgency he has created.”

Known as a shrewd politician, Sanchez has repeatedly shown his willingness to renege on public commitments or take unexpected decisions to wrong-foot his opponents. 

When his party was trounced in Andalusia’s regional election last year, the premier went on the offensive with a windfall tax on banks that shocked investors. 

Party Infighting

In 2019, he told voters that the idea of a coalition with the far-left group Podemos would prevent him from sleeping at night. A couple of months later he was sworn in to office for a second time at the head of a coalition with that group. 

In his autobiography “Resistance Manual,” Sanchez described how his parents returned to college in their 40s to get their degrees. “I have grown up surrounded by examples of non-resignation,” he said. 

Sanchez first showed his mettle following the inconclusive election result of 2016, in a scene that could potentially mirror the situation after this July’s ballot. 

With then-Prime Minister Mariano Rajoy short of a majority and unable to piece together a coalition, Socialist party elders and the Spanish establishment heaped pressure on Sanchez to abstain in order to let Rajoy take office for a second term. Sanchez refused. 

The standoff was eventually resolved by a party putsch that ousted the Socialist leader, who quit his parliament seat, and allowed Rajoy to start a second term. Against all odds, Sanchez toured the country in a grassroots campaign that won him the primaries to reclaim the party leadership, and ousted Rajoy by leading a vote of no confidence against him in parliament in 2018.  

Now Sanchez, who has survived two previous snap elections in 2019, is again betting his political future on July’s snap ballot. 

“Sanchez is used to life on the edge,”said Manuel Mostaza, head of public affairs at Madrid-based consultancy Atrevia. “But this time around it is difficult to know if he will come out on top. You can’t win them all.”

©2023 Bloomberg L.P.