Sanchez's proposal was defeated with 219 votes against and 131 in favour,with only his own party, Ciudadanos and a tiny party from the Canary Islands voting in favour.
His first attempt to win approval on Wednesday also fell well short of themark after an acrimonious debate in parliament that highlighted the country's political divisions.
It is the first time that a candidate for prime minister has lost bothconfidence votes since Spain returned to democracy following the death of dictator General Francisco Franco in 1975.
Spain has been governed by a caretaker government since a December 20election which resulted in a hung parliament divided among four main parties-none of which won enough seats to govern alone.
Parties now have until May 2 to negotiate an alternative power-sharingagreement. If they fail, new elections will be called, most likely on June 26.
Acting Prime Minister Mariano Rajoy's conservative Popular Party (PP) camefirst in the polls-which put an end to Spain's long-running two party system-but lost its absolute majority, taking just 123 seats.
Rajoy gave up trying to form a government after he failed to win supportfrom other parties fed up with years of crisis and corruption scandals.
So King Felipe VI asked runner-up Sanchez, whose Socialists scored theirworst result in history, to form a government.
After weeks of negotiations, he sealed a deal last week with upstartcentre-right party Ciudadanos.
But both the PP and new far-left party Podemos, led by pony-taileduniversity professor Pablo Iglesias, which has 65 seats, voted against Sanchez.
“I am going to keep working until I achieve this majority which our countryneeds,” Sanchez told reporters after the vote.
“Today Mr Iglesias has betrayed the millions of voters who voted for changeand he is the only one who ultimately is responsible for Rajoy continuing to be head of the government,” Sanchez added.
Rajoy bitterly dismissed the Socialist pact with Ciudadanos as “theatre”since he had not shored up the support he needed to rule anyway.
Spain has struggled to form a government because it “lacks a tradition” ofcoalition building, said political scientist Anton Losada of the University of Santiago de Compostela.
“Either there is a transversal government or we are heading towardselections,” he told AFP.
For the past three decades, Spain has been ruled by either the PP or theSocialists.
Fresh elections would leave Spain with an acting government with limitedpowers for several more months just as the country emerges from a severe economic crisis.
Spain also faces an independence threat in the wealthy northeastern regionof Catalonia which is governed by a coalition of separatist parties.
Rajoy, who wants to remain in power at the head of a “grand coalition” madeup of his PP, the Socialists and Ciudadanos that will defend national unity and budget stability, has made it known that he plans to call Sanchez on Monday to try to reach a deal.
Anti-austerity Podemos has said it is ready for talks with the Socialistsif they drop their agreement with Ciudadanos, which it sees as too economically liberal.
Podemos' number two, Inigo Errejon, said before the vote that it was stillpossible to form a coalition government of the left, with the support or abstention of small regional Basque and Catalan separatist parties.
“We have to reset the counters and start over with a clean slate,“ he said.