Spanish Prime Minister Mariano Rajoy and his government have been voted out of office in a vote of no confidence by the Spanish parliament on Friday.

Rajoy, the head of the center-right People’s Party, has served as premier since 2011, but struggled to form a governing coalition after the 2015 and 2016 general elections. He is the first Spanish premier to have been removed from power by a parliamentary vote.

The socialist PSOE party pushed for Friday’s no confidence vote, which narrowly passed by a margin of 180 to 169, with one abstention in the 350-member Spanish parliament.

PSOE chief Pedro Sanchez will replace Rajoy as Prime Minister.

“It has been an honor to be the prime minister of Spain,” Rajoy said ahead of the vote of no confidence.

“I has been an honor to leave a better Spain than the one I found. I hope that my successor will be able to say the same when his time comes.”

The ruling People’s Party had been wracked by a series of corruption scandals, including the “Gurtel Scandal”, one of the biggest corruption cases in Spanish politics in years.

Last week, dozens of senior party officials were convicted in the Gurtel Scandal, in which the People’s Party was accused of selling government contracts.