Spanish Prime Minister Mariano Rajoy was forced to step down after a vote of no-confidence in parliament Friday.

He was replaced by center-left Spanish Socialist Workers Party (PSOE) leader Pedro Sanchez, who moved the motion that led to Rajoy’s downfall.

Conceding defeat ahead of the vote, Rajoy, who came to power in 2011, said: “Pedro Sanchez will be the prime minister, and I want to be the first to congratulate him.

“It has been an honor to be the prime minister of the government of Spain. It has been an honor to leave a better Spain than the one I found. Hopefully, my replacement can say the same on his day. I wish it for the good of Spain.”

Prime Minister Mariano Rajoy, bottom right is applauded by members of his party during the second day of a motion of no confidence session at the Spanish parliament in Madrid, Friday, June 1. | Francisco Seco / AP

Sanchez, who’s move against Rajoy was supported by the anti-austerity Podemos party, said that “democracy had won.”

He welcomed the start of a new era in Spanish politics, saying: “I am reaching out to all the parliamentary groups to open these new times, and I hope that we are all up to the responsibilities that we have ahead of us.”

Rajoy’s defeat was apparent before the vote in the Spanish parliament, with the no-confidence motion passing by 180 to 169 with one abstention.

The right-wing Ciudadanos party was the only major grouping to support Rajoy’s conservative People’s Party (PP), while the Basque National Party and the left backed Sanchez’s bid to become prime minister.

Rajoy faced flak over his handling of a major corruption scandal which involved the PP allegedly running a secret campaign fund from 1999 to 2005.

Former party treasurer Luis Barcenas was found guilty of receiving bribes, money-laundering, and tax crimes earlier this month, receiving a 33-year jail sentence.

He was among 29 officials and business people convicted of securing bribes in return for municipal contracts

Podemos leader Pablo Iglesias, who himself survived a recent no-confidence vote after buying a luxury villa in Madrid, hoped that his party could join forces with the PSOE and play a role in the new government.

Iglesias wants fresh elections next year “with a plural and stable government.”

Now is the time to “leave behind a time of corruption, inequality, and confrontation,” he said.

The political crisis in Spain has caused unease across the EU, where support for the neoliberal bloc is falling due to its role in the recent instability in Italy.