(Bloomberg) -- Spain’s opposition leader failed in his second bid this week to become prime minister, falling short by four votes in parliament and paving the way for the Socialist chief Pedro Sanchez to be reelected to a new term. 

Alberto Nunez Feijoo, head of the center right People’s Party, scored 172 votes in favor and 177 against in the parliamentary ballot Friday, close to an earlier result Wednesday. Under the Spanish electoral system a nominee for prime minister faces two voting rounds, with the first requiring an absolute majority and the second simply needing more yes than no votes. 

Feijoo’s defeat underlines his party’s struggle to navigate Spain’s polarized political system — centered more around regional loyalties and local interests than ideology — which made a seemingly small gap insurmountable. Feijoo spent the last two months, since finishing first in a national election, trying to get the necessary votes. 

But for Feijoo and his party — the largest in Spain — the clearest ally is Vox, a far-right group. Vox emerged on the national scene over the past five years in large part due to its opposition regional nationalist groups —- precisely the votes Feijoo needed. Vox has the third-largest caucus in Parliament, with 33 seats.

It is now up to Sanchez to try to seal deals with multiple parties, with diverse agendas, to be elected. This task appears to be easier for him than for Feijoo. 

Sanchez, who could be sworn in for a third term as early as next month, still faces tough negotiations to convince hardline Catalan pro-independence party Junts to back him. In exchange for its seven votes, Junts has demanded an amnesty for hundreds of people involved in a failed secession bid in 2017. 

While Sanchez has not publicly committed to a wide-ranging pardon, he has said he wants a political solution to the territorial conflict that continues to divide the country.

Feijoo has called Sanchez’s potential deal with separatists unlawful and pledged that he would never accept it for himself.

“I have the votes within my reach to be prime minister, but I do not accept the price they ask for this,” Feijoo said earlier this week, referring to Junts.

Junts is led by Carles Puigdemont, who as regional president of Catalonia sought to declare independence from Spain but failed in October 2017. As Madrid moved to put the region under its direct control, Puigdemont fled the country to escape arrest and has lived in Belgium since then fighting extradition orders.

Junts had played marginal roles in the political scene in recent years under Sanchez, but found itself unexpectedly in the role of king-maker after July’s election. The amnesty the party is seeking would benefit Puigdemont. 

©2023 Bloomberg L.P.