If the parties vote as they say they will, only a last-minute resignation can prevent Rajoy from becoming the first Spanish prime minister to be ousted in a motion of no confidence.
Spanish Prime Minister Mariano Rajoy has been forced out of office by a no-confidence vote in parliament.
Socialist party head Sanchez becomes Spain's seventh Prime Minister since its return to democracy in the late 1970s following the dictatorship of Francisco Franco.
The bespectacled 63-year-old leader got up and shook hands with Sanchez before leaving the lower house without a word.
Mr Rajoy became Spain's first sitting Prime Minister to stand witness in a trial over the corruption cases, believed to have taken place between 1999 and 2005, and many called for him to resign.
He has already committed to respecting a budget passed by Rajoy, and the fragmented parliament means Sanchez will find it hard to row back on structural reforms passed by his predecessor, including new labor laws and cuts in healthcare and education.
That was until last week's ruling by the National Court that delivered hefty prison sentences to 29 business people and ex-members of Rajoy's Popular Party, including some elected officials, for fraud, money laundering and tax evasion, among other crimes.
Sanchez, often criticized as lacking a feel for the moment, pounced and left lawmakers with the choice of keeping a party thoroughly tarnished by corruption in charge or making a fresh start.
As such, even if he has pledged to govern long enough to restore "institutional stability" before calling early elections, Sanchez's new government will likely be highly unstable.
Sanchez had been Rajoy's most loyal backer in his takeover of Catalonia's regional government following its failed secession attempt past year.