Zuma railed against the African National Congress (ANC) for “recalling” him from office and threatening to oust him via a parliamentary no-confidence vote due on Thursday.
In a 30-minute national television address, Zuma said he had “come to the decision to resign as president of the republic with immediate effect”.
Ramaphosa, who won control of the ANC when he was elected as its head in December, is set to be voted in by lawmakers as South Africa’s new president on Thursday or Friday.
Zuma, whose reputation has been stained by years-long allegations of graft, complained that the ANC party had never explained to him why he had to leave office.
In an earlier TV interview on Wednesday, he said he had received “very unfair” treatment from the party he joined in 1959 and in which he had fought for decades against apartheid white-minority rule.
He said he was angered over “the manner in which the decision is being implemented… I don’t agree as there is no evidence of if I have done anything wrong.”
The party’s national executive committee ordered his recall from office on Tuesday, after a 13-hour meeting at a hotel outside Pretoria.
ANC officials had said that if Zuma did not resign on Wednesday, the party’s lawmakers in the Cape Town parliament would vote out Zuma on Thursday.
But senior party official Jesse Duarte said after the resignation that “we are not celebrating”.
On Wednesday morning, police had raided the Johannesburg home of the Gupta business family, which is accused of overseeing a web of corruption under Zuma’s rule.
Police said three unidentified people had been arrested in investigations into “Vrede Farm” — allegations that millions of dollars of public money meant for poor dairy farmers were syphoned off by the Guptas.
Local media reported that Zuma had been pushing for an exit deal that included covering his potentially ruinous legal fees fighting multiple criminal charges — but he denied the allegations in his resignation speech.
One case against him relates to 783 payments he allegedly received linked to an arms deal before he came to power.