BARCELONA, Spain — Mariano Rajoy, Spain’s caretaker prime minister, is set to form a new government, after the main opposition party, the Socialists, voted on Sunday not to block his re-election.

The federal committee of the Socialist Party voted 139 to 96 in favor of abstaining from a parliamentary vote next weekend that would allow Mr. Rajoy to continue in office and avoid a third national election, after 10 months of political deadlock.

Mr. Rajoy will have to lead a minority conservative government that faces serious territorial and budgetary challenges.

Spain has been threatened with a European Union fine for failing to meet deficit targets agreed upon with Brussels. And the separatist regional government in Catalonia has pledged to hold an independence referendum in 2017, despite fierce opposition from Madrid and Spanish courts.