Sanchez, who won the most seats in an election in April but fell short of a majority, has faced three months of difficult coalition talks with Podemos, whose votes he needs to be confirmed as prime minister.
He has led the government as a caretaker in the interim, but could be forced to hold new elections if he cannot win confirmation.
After a few tense days where the two parties seemed at turns within reach of a deal or on the point of breaking off talks entirely, Podemos ended up abstaining on Tuesday, rather than voting against Sanchez. Officials in both parties described that as a gesture of good will to allow negotiations to continue.
“We will keep working so that there is a coalition government. Time is running out,” Podemos lawmaker Ione Belarra said after the vote. “Our last gesture was to abstain in order to make the negotiations easier.”
Sanchez was not expected to win Tuesday’s vote, but he lost it by a wide margin, with 124 votes to 170, and 52 abstentions.
Only one lawmaker outside his Socialist party voted for him.
To win Tuesday’s vote, Sanchez would have required an absolute majority of 176 votes in the 350-seat parliament. A second round on Thursday will operate under different rules, requiring only a simple majority excluding abstentions.
Still, he faces an uphill struggle to convert abstentions and some ‘no’ votes into votes in his favor.
All will depend on whether the Socialists and Podemos set aside their differences to strike a deal for a coalition government and also get support from smaller, regional parties.
Socialist spokesperson Adriana Lastra said: “It is the moment to form a government of the left. We have the basis for an understanding.”
Considering how difficult talks have been over the past three months, and tense exchanges between Sanchez and Podemos leader Pablo Iglesias in a parliament debate late on Monday, it remains to be seen how stable and united such a government would be.
If Sanchez is not confirmed as prime minister on Thursday, further votes could be held in September. If that failed too, a repeat election would be held on November 10.
Still, the mood appeared to be calmer on Tuesday.
Sources in Podemos and the Socialist party said that the main question was what role Podemos ministers would have.
Rejecting Podemos’ accusations that its ministers would only have a “decorative” role with no power, chief Socialist negotiator Carmen Calvo said Irene Montero, a senior Podemos lawmaker, had been offered the deputy premiership.
Unlike the other Podemos lawmakers, Montero voted ‘no’ on Tuesday. But Podemos officials said this was because Montero, who is pregnant, voted early in the morning from home, before the party changed its mind and decided to abstain.