Spanish Prime Minister Mariano Rajoy resigned ahead of a no-confidence vote in the country’s Parliament on Friday, local daily El Pais reported.

“[Spanish Socialist Workers’ Party Secretary General] Pedro Sanchez will be the prime minister of the government and I want to be the first to congratulate him,” Rajoy said. “It has been an honour to leave a better Spain than the one I found.”

Rajoy’s People’s Party has been implicated in a corruption scandal, BBC reported. The case involves a secret campaign fund the party ran from 1999 to 2005. The Madrid High Court last week convicted Luis Barcenas, one of the party’s former treasurers, of receiving bribes, money laundering and crimes related to taxation. Subsequently, Sanchez moved a no-confidence motion.

Sanchez secured the backing of six smaller parties for the trust vote on Thursday, giving him the majority he needed to become the prime minister, Reuters reported. The opposition needed 176 votes to win the motion in Congress. A graphic on El Pais showed 180 legislators voting in favour of the motion, while 169 voted against it.

“A new era in Spanish politics is beginning,” Sanchez’s party quoted him as saying after Rajoy resigned. Spain’s King Felipe VI will now officially name Sanchez the head of the government.