Mr. Rajoy’s removal also ignited a feud with Ciudadanos, which wanted to force another election.
During the parliamentary debate, Albert Rivera, the leader of Ciudadanos, repeatedly voiced his frustration over Mr. Rajoy. Mr. Rajoy was not in Parliament to listen, however, instead spending more than seven hours on Thursday in a Madrid restaurant.
Mr. Rivera also accused Mr. Sánchez of taking office through the back door without first getting elected. He said Mr. Sánchez was forming a “Frankenstein government,” reliant on far-left politicians and regional parties that want to break up Spain.
In contrast, Mr. Rajoy used his farewell address in Parliament to congratulate Mr. Sánchez. He also highlighted his own contribution, saying that he would now “leave Spain better off than I had found it.” Mr. Rajoy added, “Hopefully my replacement will be able to say the same when his day comes.”
Not least among those dancing on Mr. Rajoy’s political grave were Catalonia’s separatist parties, which have been locked in a bitter struggle with the former prime minister. They held Mr. Rajoy’s administration responsible, alongside Spain’s judiciary, for jailing many of their leaders on charges of rebellion after their botched attempt to declare unilateral independence in October.
Mr. Sánchez’s takeover in Madrid coincides with the start of a new separatist administration in Barcelona, the capital of Catalonia, led by Quim Torra. Mr. Sánchez is expected to meet soon with Mr. Torra, whom he recently called a “racist,” in reference to past insults leveled by Mr. Torra against Spaniards and their values.
Carles Campuzano, a separatist lawmaker, told Spanish national television that his party had only endorsed Mr. Sánchez because he seemed to understand that “the Catalan question is not a legal question but one that requires listening, understanding and proposing solutions.”
Mr. Campuzano added, “We chose the least bad of the options, which was for Rajoy to leave.”
On Friday, Íñigo Errejón, a leader of the Podemos party, told reporters that it was too early to predict what Mr. Sánchez could achieve with his new allies. But he said that opposition lawmakers had taught the cautious Mr. Rajoy an unlikely lesson in parliamentary tactics.
“We’ve got rid off Rajoy,” said an elated Mr. Errejón. “He was here as if he was a geological feature of our country.”