A total of 124 lawmakers in the 350-seat parliament voted for the Socialist premier in Tuesday's vote, leaving him well short of the absolute majority he needed.
A second, decisive vote has been scheduled for Thursday afternoon, as Sanchez needs to reach a coalition deal with left-wing progressive Unidas Podemos party. If he manages to form a coalition government, it would be the first in post-dictatorship Spain.
If he fails to reach an agreement, Spain will hold its fourth elections in as many years.
Sanchez is currently caretaker premier after coming first in the April general election but without the majority he needed with just 123 seats, forcing him to look for support. Unidas Podemos lawmakers abstained to vote, while Catalonia's pro-independence party ERC voted against Sanchez.
The second vote on Thursday requires only a simple majority. With the support of Unidas Podemos' 42 lawmakers and a few others from small regional parties, he could get through.
Sanchez's Socialist party has been locked in negotiations with Pablo Iglesias' Unidas Podemos for months and only recently reluctantly agreed to form a coalition government with them.
But Iglesias accused the socialists of refusing to give his party ministerial positions that carry any kind of weight and wanting them to be "mere decoration" within the government, in a parliamentary debate on Monday.
�� @SimancasRafael: El próximo jueves nos jugamos que España tenga gobierno o no, que avance o se bloquee.
La mayoría de las y los españoles quieren que España tenga un Gobierno y avance. #SíParaAvanzar
Next Thursday we shall see whether Spain has a government or not, that advances or gets stuck. Most Spaniards want Spain to have a government and move forward.
Catalan pro-independence party ERC, meanwhile, accused Sanchez of being "irresponsible" for not appearing to want to negotiate with anyone.
It also slammed him for not having mentioned the situation in Catalonia in his Monday speech to parliament.
ERC had previously said it would not stand in Sanchez's way despite their differences over how to handle the crisis, which culminated in a failed declaration of independence on October 2017.
"The feeling was that you are playing poker with the hopes of hundreds of thousands of people who came out to vote on April 28," Gabriel Rufian, ERC's leader in parliament, said.
Aitor Esteban of the PNV Basque nationalist party said the socialists had not even been in touch with them in the past few weeks. "They have taken for granted that our vote was going to be positive," he added.
His party also abstained in Tuesday's vote.
If Sanchez cannot secure the votes he needs on Thursday, he has another two months to find a solution, if not the Spanish people will face another general election.