Spain's new Prime Minister and Socialist party (PSOE) leader Pedro Sanchez shakes hands with ousted Prime Minister Mariano Rajoy
Spain's new Prime Minister and Socialist party (PSOE) leader Pedro Sanchez shakes hands with ousted Prime Minister Mariano Rajoy after a motion of no confidence vote at parliament in Madrid, Spain, June 1, 2018. Pierre-Philippe Marcou/Pool via Reuters

Spain voted out its prime minister of more than six years in a no-confidence motion on Friday. Mariano Rajoy, who conceded defeat before the vote, was replaced by Socialist Pedro Sanchez, who won a slim majority of 180 votes.

Rajoy was unseated following corruption convictions last week involving four members of his centre-right party. His ouster was the first in four decades of democracy since the dictatorship of Francisco Franco.

Spain's Prime Minister Mariano Rajoy
Spain's Prime Minister Mariano Rajoy gets into his car during a lunch break in a motion of no confidence debate at Parliament in Madrid, Spain, May 31, 2018 Reuters/Sergio Perez

He was the first to congratulate his successor, Sanchez, who got the support of the Basque Nationalist Party, two Catalan pro-independence parties, as well as the Podemos party.

“It has been an honour to leave Spain better than I found it,” Rajoy told lawmakers. “Thank you to all Spaniards and good luck.” He had been the prime minister since December 2011.

Sanchez, who won the vote 180-169 with one abstention, is expected to be sworn in by King Felipe VI as early as Saturday morning. He will be the country’s seventh prime minister since the 70s.

Spain's Socialist (PSOE) leader Pedro Sanchez
Spain's Socialist (PSOE) leader Pedro Sanchez listens to Spain's Prime Minister Mariano Rajoy (not pictured) during a motion of no confidence debate at Parliament in Madrid, Spain, May 31, 2018. Reuters/Sergio Perez

His remarkable rise to power was almost prematurely ended in 2016 when he was ousted by his own party’s elites after he tried to block Rajoy’s bid to form a government. He regained leadership in May 2017 after winning an internal party election against Susana Diaz.

Sanchez said his priorities as the new PM will be social issues. He also said he would build consensus among political parties to modernise the country. He and his Spanish Socialist Workers’ Party are supporters of the European Union and the euro.