JOHANNESBURG — President Jacob Zuma of South Africa, a master tactician who survived a string of corruption scandals and harsh court judgments during his nearly nine-year presidency, agreed on Wednesday night to step down, repudiated by the governing African National Congress Party, threatened by a no-confidence vote in Parliament, cornered by opposition parties and abandoned by millions of voters.

In an address to the nation Wednesday night, Mr. Zuma said he was resigning even though he disagreed with the party’s decision ordering him to do so.

“I have therefore come to the decision to resign as president of the Republic with immediate effect, even though I disagree with the decision of the leadership of my organization,” he said at the end of a lengthy address on television. “I have always been a disciplined member of the A.N.C.”

It was a humiliating end for Mr. Zuma, a charismatic anti-apartheid hero who was imprisoned on Robben Island with Nelson Mandela and was once the A.N.C.’s intelligence chief. Cyril Ramaphosa, the deputy president whose election as A.N.C. leader in December set off a power struggle with Mr. Zuma, immediately became acting president.