Spain's acting prime minister, Pedro Sanchez, during the second day of the investiture debate. | Sergio Perez

Spain's Socialist leader Pedro Sanchez failed today in a first attempt to get parliament's backing to form a government, leaving him two days to try and strike a deal with the far-left Unidas Podemos ahead of a second vote.

Sanchez won the most seats in an election in April but fell short of an absolute majority, requiring him the support of other parties to be confirmed as prime minister.

He lost today's vote by 124 votes to 170, with 52 abstentions. He would have needed a full majority of at least 176 votes to be confirmed as prime minister.

On Thursday he will only need a simple majority - more 'yes' than 'no' votes - and much can change until then.

All will depend on whether PSOE and Podemos set aside their differences to strike a deal and also get support from smaller, regional parties.

Relations have been tense over the past few days with Podemos, but both sides have said they want to keep negotiating to try and hammer out a coalition government deal.
Considering how difficult talks have been over the past three months, and there were tense exchanges between Sanchez and Iglesias in the parliament debate on Monday, it remains to be seen how stable and united such a government would be.

Sources in Podemos and PSOE said that the main question was what role Podemos ministers would have.

If Sanchez is not confirmed as prime minister on Thursday, further votes could be held in September. If this were to also fail, a repeat election would be held in November.