Opposition Socialist leader Pedro Sanchez was sworn in Saturday as Spain’s new prime minister, taking over the premiership after Prime Minister Mariano Rajoy lost a parliamentary confidence vote Friday.

Spain’s King Felipe VI administered the oath of office in a ceremony at the Zarzuela Palace near Madrid.

Sanchez won the no-confidence motion with 180 votes in favor, 169 against and 1 abstention in the 350-seat lower house. It was the first ouster of a serving Spanish leader by parliament in four decades of democracy.

Rajoy lost the vote after six years in office, following corruption convictions last week involving former members of his center-right Popular Party.

Sanchez, leader of the Spanish Socialist Workers’ Party, becomes Spain’s seventh Prime Minister since its return to democracy in the late 1970s, following the dictatorship of Francisco Franco.

Sanchez still must name his Cabinet, and it is only when their names are published in an official government journal that he will fully assume his duties.