Bar any last minute u-turns, this will be the first time since Spain transitioned back to democracy after the 1975 death of Francisco Franco that a prime minister is toppled by a vote of no-confidence.
But Rajoy's departure after six years in office casts one of the euro zone's top four economies into an uncertain political landscape, just as another - Italy - pulled back from early elections.
Mr Rajoy is the first prime minister in modern Spanish history to be defeated in a no-confidence motion.
Mr Sanchez, 46, is expected to take office by Monday after King Felipe VI swears him in, and appoint his cabinet next week.
He put Spain back onto the path of growth after a devastating economic crisis although unemployment remains sky-high, jobs precarious and many complain inequalities have risen.
And it was another graft scandal that prompted the Socialists to table the no-confidence motion after a court said it had uncovered a vast system of bribes given to former PP officials in exchange for lucrative public contracts between 1999 and 2005.
More than 8,000 Starbucks to close for anti-bias training
About 7,000 licensed stores, including those in hotels, universities, grocery stores and airports, will be open. Each store will receive a tool kit which will allow for partners to learn together in small self-guided groups.
Rajoy, one of Europe's longest-serving heads of government, lost the vote following corruption convictions last week involving former members of his conservative Popular Party.
Rajoy went to shake hands with Sanchez after the result was announced. The National Court in Madrid last week handed down prison sentences to the tune of a combined 351 years to 29 people in connection with a slush fund set up in the 1990s and early 2000s to illegally finance PP campaigns.
The former economics professor regained the Socialists' leadership past year.
Sanchez, who became prime minister with only 84 seats for his Socialists in the 350-member assembly thanks to support from the hard-left Podemos and smaller nationalist parties, said he intends to steer the country through to mid-2020 when the parliamentary term ends.
The party holds a crucial five seats in parliament and has already informed both leaders of its intentions, according to Basque newspaper El Correo.
"The PP has had corrupt people, I acknowledge it but the PP is not a corrupt party", he said, before accusing Sanchez of "opportunism at the service of personal ambition". Judges did not find that current government members had committed any wrongdoing.