Zuma announced he had stepped down in a late-night television address in which he took some digs at the African National Congress (ANC) party that had threatened to oust him via a parliamentary no-confidence vote.
In a 30-minute speech, Zuma said he had "come to the decision to resign as president of the republic with immediate effect".
"I have only asked my party to articulate my transgressions and the reason for its immediate instruction that I vacate office," he said.
South Africa's Zuma resigns, forced out by own party
Zuma, 75, had been in a divisive power struggle with Ramaphosa, the deputy president.
Ramaphosa, who won control of the ANC when he was elected as its head in December, was expected to be voted in by parliament as South Africa's new president on Thursday, according to local media.
Zuma, in an earlier TV interview on Wednesday, said he had received "very unfair" treatment from the party that 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 Zuma's recall from office on Tuesday, after a 13-hour meeting at a hotel outside Pretoria, but he at first refused.
South Africa's ANC to remove Zuma as head of state
ANC officials then said that if Zuma did not resign, the party's lawmakers in the Cape Town parliament would vote out him on Thursday.
But party deputy secretary general Jesse Duarte said after the resignation that "we are not celebrating".
"We have had to recall a cadre of the movement that has served this organisation for over 60 years, it's not a small matter," she added.
Zuma, who had no formal education, was jailed on Robben Island for ten years alongside Nelson Mandela under apartheid and rose through the ranks of the ANC to take power in 2009.
But his rule was dominated by graft scandals, economic slowdown and falling popularity for the celebrated liberation party.
S.Africa's Zuma vows free higher education
In a day of high drama, police on Wednesday morning had raided the Johannesburg home of the Gupta business family, which is accused of overseeing a web of corruption in Zuma's government.
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 a resignation deal that included his legal fees to fight multiple criminal charges 0 - 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.
Other graft allegations have centred on the three Gupta brothers, who are accused of unfairly obtaining lucrative government contracts and even being able to choose Zuma's ministerial appointments.
The political standoff in recent weeks plunged South Africa - the continent's most developed economy - into confusion over who was running the country, with last Thursday's annual State of the Nation address cancelled at the last-minute.
Zuma, a Zulu traditionalist with four wives and a proud singing voice, had been scheduled to stand down next year after serving the maximum two terms.
In local polls in 2016, the ANC recorded its worst electoral result since coming to power in 1994 with Mandela at the helm as white-minority rule fell.
Ramaphosa, 65, must revive the economy and crack down on what he has admitted is rampant government corruption if he is to boost the party's tarnished reputation before a tricky election next year.
He is a former trade unionist and Mandela ally who led talks to end apartheid in the early 1990s and then became a hugely wealthy businessman before returning to politics.
Zuma's hold over the ANC was broken in December when his chosen successor - his former wife Nkosazana Dlamini-Zuma - narrowly lost to Ramaphosa in a vote for the new party leader.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ