But Sanchez appeared on track to win a second confidence vote later in the coming week.
Sanchez needed 176 votes — an absolute majority in the 350-seat assembly — to be confirmed as prime minister for another term.
He lost the vote as expected, with 166 in favour, 165 against and 18 abstentions. One lawmaker did not attend the vote due to illness.
Sanchez will face parliament again on Tuesday and this time he needs a simple majority — more yes votes than no — to be become premier for another term.
While the political math works in his favour after he struck a deal for the 13 lawmakers from Catalan separatist party ERC to abstain, the numbers still look tight. At the latest count Sanchez could win on Tuesday by a margin of just two votes.
Spain, the eurozone's fourth-largest economy, has been in political gridlock without a proper government for most of the past year after two inconclusive elections in April and November.
Sanchez's Socialists won the repeat November 10 polls but were weakened, taking 120 seats, three fewer than in April.
He quickly struck a deal with hard-left party Podemos, which won 35 seats, to form what would be the first post-dictatorship coalition government in Spain.
With the two parties' combined total of 155 seats still falling short of a majority, Sanchez has also secured the support or abstention of several smaller regional parties including the ERC to squeak by in a second vote.
Sanchez, 47, defended his team's manifesto during a rare weekend session of parliament ahead of Sunday's first confidence vote.
He is pledging to lift the lowest salaries and raise taxes for high earners and large businesses, while moderating elements of Spain's controversial 2012 labour market reforms that made it easier to fire workers.
Sanchez also said dialogue would be an “absolute priority” to resolve a conflict over Catalonia's independence drive and stressed the need to acknowledge the frustrations of both those in favour and against secession
for the wealthy northeastern region.
The political situation in Catalonia remains in flux following a 2017 independence referendum which Madrid declared unconstitutional.
“This progressive coalition is the best antidote against this coalition of the apocalypse,” Sanchez said Sunday in a reference to Spain's conservative parties — the Popular Party (PP), Ciudadanos and far-right Vox — who accuse him of betraying the constitution by his deal with Catalan separatists to form a government.
PP leader Pablo Casado accused Sanchez of forming a “Frankenstein government” made up of “communists” and “separatists” who “want to put an end to Spain”.
Sunday's vote came on the eve of the celebration of the Epiphany on January 6, the day Christians observe the visit the Three Kings made to the baby Jesus and a major holiday in Spain when Christmas gifts are traditionally exchanged.
Many lawmakers arrived at the assembly with suitcases to head to the airport or train station after the vote and go to their hometowns for the holiday.
Until 2015, Spain had essentially a two-party system pitting the Socialists against the PP but the rise of new parties has led to a more fragmented parliament that has made it harder to form a government.
Sanchez came to power in June 2018 after ousting his PP predecessor Mariano Rajoy in a no-confidence vote.