Mariano Rajoy has been ousted as Spain’s prime minister in a vote of no confidence after several former members of his party were convicted on corruption charges.

He will be replaced by Pedro Sanchez, the leader of Spain’s opposition socialist PSOE party, which tabled the motion against Rajoy.

The motion was passed after a bitter two-day debate in parliament, which ended in Rajoy losing the vote by 180 to 169 votes.

Rajoy appeared in parliament Friday morning and in a brief speech said, “I will accept the decision.”

“It has been an honor to be the leader of Spain and to leave it in a better state than the one I found. I believe I have satisfied my responsibility, which is to improve the lives of Spaniards. If I have offended someone in my role, I ask forgiveness,” he told the press after his resignation.

Sanchez, Spain’s new prime minister, only regained his leadership a year ago, after a PSOE coup saw him deposed over his refusal to let Rajoy back into office following two inconclusive general elections.

He vowed to address the nation’s pressing social needs after years of austerity under the pervious conservative government.

In a statement, the Party of European Socialists (PES) welcomed Sanchez as Spain’s new prime minister, adding that it looked forward to his government forming a credible alternative for Spain.

“We warmly welcome the election of Pedro Sanchez, a progressive and honest pro-European, to lead the next government of Spain. He will shift away from the austerity policies of the past years in his country and we are confident that, together with our political family, he will contribute to ending austerity at the European level as well,” said PES president Sergei Stanishev.

"I would like to congratulate Pedro personally. I am looking forward to working with him and welcoming him in Brussels."