But Rajoy’s departure after six years in office casts one of the European Union’s top four economies into an uncertain political landscape, just as another – Italy – pulled back from early elections.
Sanchez won Friday’s no-confidence motion with 180 votes in favour, 169 against and 1 abstention.
He suggested on Thursday he would try to govern until the scheduled end of the parliamentary term in mid-2020. But it is unclear how long his administration, with only 84 Socialist deputies in the 350-member legislative assembly, can last.
Sanchez, who is expected to be sworn in by Monday and appoint his cabinet next week, has promised to start talks with the Catalans but said he will not give them an independence referendum.