Sanchez saw that as his opening and managed to muster enough support from smaller parties to send him to La Moncloa palace, the seat of government in Madrid.
Local analysts believe that the situation reflects the weakness of Spain's politics and economy when facing special situations, because corruption has chased the ruling PP in recent years, while in the economic scenario, public debt, deficit, unemployment or lack of innovation, are still problems to be solved in the country.
Analysts said Rajoy, who has been in power since 2011, would be politically weakened if the motion fails, with opposition parties expected to press further efforts to topple him.
Mr Rajoy was having none of it, accusing Mr Sanchez of a power grab.
"I am aware of the responsibility I am assuming, of the complex political moment our country is going through and I will rise to all the challenges with humility and dedication", Sanchez told reporters.
He vowed to build consensus among political parties to "transform and modernize" Spain and "address the social urgencies of many people who suffer precariousness and inequality".
Lawmakers from the Basque Nationalist Party (PNV) announced Thursday that they would back Socialist leader Pedro Sánchez's motion of no confidence in Rajoy in a vote to be held Friday.
But he will struggle to govern as his Socialists have just 84 seats in the 350-seat parliament.
In 2003 he took a position as a city council member in Madrid and then climbed up the Socialist party ladder, first becoming an MP and then party leader in 2014.
The dispute over the Catalan illegal independence declaration past year had dogged his second term, but it is longstanding corruption scandals staining his party's reputation that look set to bring down his government.
Deposed leader Carles Puigdemont, now under arrest in Germany, faces sedition charges if he returns to Spain, and efforts to replace him have sparked further controvery.
In parliament on Thursday, Mr Sanchez presented his case that Mr Rajoy must go because Spain "is sick and exhausted of serial corruption".
MARIANO RAJOY, Spain's Prime Minister, looks set to be defeated in a vote of censure (no confidence) today after opposition parties agreed to back his ousting yesterday.
In a brief speech before the vote, Rajoy told lawmakers "it has been an honor to leave Spain better than I found it".
Born in 1955 in Santiago de Compostela in the conservative northwestern Galicia region, Rajoy is the eldest son of a provincial court president.
"We also have taken note of the commitment made by the new prime minister Sanchez not to modify the budget", added Juncker's spokeswoman Mina Andreeva. The final vote has been called for 0900 GMT.
Sanchez, 46, is now the prime minister in waiting.
The Spanish Socialist Workers' Party leader Sanchez won the parliamentary confidence vote with 180 votes in favour, 169 against and one abstention.
Pastor has gone to audience hall with a Garnet folder of those used in Congress and has posed in that place with serious gesture with Felipe VI, before moving to his official office to realize outcome of vote of motion of censure held This morning in lower house.