JOHANNESBURG -- South African President Jacob Zuma said he has resigned "with immediate effect." The scandal-tainted leader made the announcement late Wednesday in a televised address to the nation, avoiding his almost certain ouster in a parliamentary vote scheduled for Thursday after years of corruption scandals.

Zuma's resignation came after the ruling African National Congress party instructed him to leave office by the end of Wednesday or face the motion of no confidence in parliament. His departure ended a leadership crisis in one of Africa's biggest economies and set the stage for ruling party lawmakers to elect acting president Cyril Ramaphosa, previously deputy president, as Zuma's successor.

"I have served the people of South Africa to the best of my ability," Zuma said, AFP reported. "I am forever grateful that they trusted me with the highest office in the land."

Get Breaking News Delivered to Your Inbox

"I don't fear exiting political office however I have only asked my party to articulate my transgressions and the reason for its instructions that I vacate office," he said.

Zuma's tenure has been marred by years of corruption scandals. He has been in a vulnerable position since December, when his rival, Ramaphosa, was chosen to lead the party, the BBC reports.

South Africa's ruling party welcomed Zuma's resignation after months of growing public anger over multiple corruption allegations. The ANC expressed gratitude for Zuma's "loyal service" and issued a statement saying his resignation provided "certainty to the people of South Africa."

It also encouraged party members to support Ramaphosa, who is expected to be elected swiftly in a parliament vote and sworn in.

The former president was defiant in a television interview earlier Wednesday, saying he had done nothing wrong. "I'm being victimized here," Zuma told state broadcaster SABC. He complained that Ramaphosa and other ANC leaders had not given him clear reasons about why he should go.

On Wednesday morning, police raided the home of prominent business associates of Zuma who are accused of being at the center of corruption scandals that have infuriated the country, hurt the ANC's popularity and weakened the economy. An elite police unit entered the compound of the Gupta family, which has been accused of using its connections to the president to influence Cabinet appointments and win state contracts. The Guptas deny any wrongdoing.

Several people were arrested during police operations, South African media reported.

The ANC, which has led South Africa since the end of white minority rule in 1994, had wanted Zuma to end his second five-year term early so that it could build up support ahead of 2019 elections.

"We can no longer keep South Africa waiting," said Paul Mashatile, the ANC's treasurer general.

Zuma had been in power since 2009.