MADRID (Reuters) - Spain’s conservative leader Mariano Rajoy was on course to secure a second term in power for his People’s Party (PP) on Sunday after his Socialist rivals agreed to abstain in a looming confidence vote, ending 10 months of political deadlock.

Spain's acting Prime Minister and People's Party (PP) leader Mariano Rajoy attends a military parade marking Spain's National Day in Madrid, Spain October 12, 2016. REUTERS/Juan Medina

Spain has been stuck in political limbo following national elections in December and June which left no single party with a majority, paralyzing institutions and threatening to derail an economic recovery.

With a third ballot on the cards the center-left Socialists, traditional opponents of the PP, ceded ground on Sunday in an extraordinary, internal party meeting to choose between a third general election or allowing Rajoy to govern.

Senior party members voted by 139 to 96 in favor of abstaining in a parliamentary confidence vote to be held this week.

Rajoy’s minority government will have to contend with a hostile, deeply fragmented parliament over the next four years, opening up a fresh source of political instability for Spain.

His prime task will be to keep on track an economic rebound after years of recession, while cutting costs to meet stringent deficit targets.

December’s election broke the stable two-party system that has ruled Spain since the death of dictator Francisco Franco in the 1970s, and a re-run in June delivered a similar result as new parties grabbed millions of votes in the wake of a deep recession.

Rajoy’s PP beat the Socialists in both elections, followed by the upstart Podemos (“We Can”) and Ciudadanos (“Ciudadanos”) parties, which together secured close to a third of parliamentary seats.

To govern, Rajoy needed sufficient support or an abstention by his rivals in a confidence vote. That two-stage ballot will now take place this week, with the second vote due on Saturday or Sunday.

The Socialists had blocked Rajoy’s reelection under their former leader Pedro Sanchez, a stance that would have forced Spain into its third election in a year.

Sanchez was forced to resign earlier this month by his party, who feared the Socialists would suffer an electoral bloodbath if they triggered a fresh poll.

Defending the vote, Socialist interim party head Javier Fernandez said the result was the least bad of the two options.

“We went to win the elections, but since that didn’t happen, we need that there is a government to act as the opposition,” he said.

TOUGH FOUR YEARS

Rajoy enjoyed an absolute majority in parliament after taking power from the Socialists in 2012, but his popularity was eroded by austerity measures and a series of corruption scandals that tainted the PP.

Rajoy’s PP has 137 seats in the 350-strong lower house of parliament, the rest split between the now-leaderless Socialists, the anti-austerity Podemos and market friendly Ciudadanos.

Those divisions will complicate his stewardship of an economy that is straining to cut one the highest public deficits in Europe and to shrink its public debt, which has almost tripled since the start of the crisis.

First on an expanding to-do list for the new government will be updating the emergency 2017 budget to better reflect the deficit targets set by Brussels. Rajoy needs to find at least 5 billion euros in extra revenues or spending cuts.