Mariano Rajoy told a meeting of senior leaders in Madrid on Tuesday morning that he will resign as leader of the Popular Party (PP) "as soon as you elect another one" as part of a process of political transition.
The party will hold an extraordinary conference to elect that new leader.
"The time has come to bring this to an end and for the PP to continue under someone else's leadership", he said, having concluded that the PP must "defend its work" over the past few years "and get back in government as soon as possible".
"I have tried to be fair and protect the good name of our party."
The now former Prime Minister said the future of the country was "very uncertain" and that the new PSOE government "extremely weak" after choosing "disastrous" travelling companions in EH Bildu (radical Basque nationalists) and Catalan separatists.
He said last week's motion of no confidence set a "very grave precedent set in Spanish democracy" and that a "stigmatised" Socialist Party had taken power with "someone who lost elections".
Other parties had been "manipulating and lying" about the Gürtel fraud judgement, which led to him being ousted.
"Mr. Sánchez never gave up on the idea of a Frankenstein government", said Mr. Rajoy, explaining the PSOE had rejected an offer two years ago to form a grand coalition when two general elections returned a lower house of parliament split four ways between the PP, the PSOE, Podemos and Ciudadanos.
The senior PP leaders listening applauded when Rajoy criticised Ciudadanos, a party, Mr. Rajoy said, that "does not know how to stand up to Catalan separatism".
"We applied Article 155 [of the Constitution, to suspend home rule in Catalonia] for the first time."
He also said his government "never negotiated anything with [Basque terrorist group] ETA […] we have never moved [ETA] prisoners closer to the Basque Country".
Mr. Rajoy said no one really talked about Spain's risk premium any more and that 2.7 million jobs had been created during his time in government.
Subscribe Now To Understand Spain Better, In English
Spain is a fascinating country, its history full of intriguing characters and events, and the story is not over yet.
Catalan independence, Podemos, corruption, economic recovery and now a political crisis that might bring Rajoy's government down.
The truth still needs to be told, power still needs holding to account. Our collective futures depend on our ability to understand how our societies are evolving.
The Spain Report gives you fast reporting and deeply informed analysis of the latest news, events and trends changing this wonderful country, in English.
Your subscription guarantees our news and analysis are 100% independent.