But despite his role in the struggle against apartheid, Mr. Zuma did not surprise those who predicted from the start that his presidency would be troubled. Even before he became the nation’s leader, he had been dogged by scandal and corruption charges. He spent much of his presidency fighting similar battles in the courts, Parliament and the public.
Most South Africans will remember Mr. Zuma for his personal ethical problems, especially those related to his homestead, Nkandla. His stubborn reluctance to pay what amounted to a relatively modest sum of about $650,000 for personal upgrades to his home led to outsize consequences: court judgments, invigorated opposition parties and the erosion of public trust.
Among voters, Mr. Zuma helped precipitate the decline of the A.N.C., a party that, thanks to its heroic liberation past, had seemed invincible at the polls just a few years earlier.
As he steps down, Mr. Zuma may be regarded as the weakest leader in South Africa’s post-apartheid history. His tenure lacked lasting policy successes. His words, actions and appointments repelled investors and often sent the local currency, the rand, spiraling lower.
At the same time, he reflected the problems of a party that has struggled to transform itself from a liberation movement to a modern political party, and that has led, mostly unchallenged, for a quarter of a century.
The A.N.C. unfailingly stood behind Mr. Zuma until the end of his second term as party leader in December and the election as party leader of Mr. Ramaphosa, an anti-apartheid leader who went on to become one of the nation’s most successful businessmen.
Even after that, a sizable faction fought fiercely for Mr. Zuma to complete his full term.
“South Africa’s downward trajectory cannot be blamed on Zuma alone,” Ralph Mathekga, the author of “When Zuma Goes,” wrote. “He is, after all, just one man and part of a much bigger system.”
An economic populist, Mr. Zuma spoke often of a “radical economic transformation” to make South Africa work better for the vast impoverished black underclass that had been left behind during the rapid years of growth under his archrival, Mr. Mbeki. But under Mr. Zuma, the country’s economy stagnated.
Government debt was downgraded to junk status because of poor governing. Unemployment topped 25 percent, and the nation remained one of the world’s most unequal societies.
The police massacre of 34 miners involved in a wildcat strike in Marikana in 2012, the worst act of official violence since the end of apartheid, intensified the widespread belief that the A.N.C. had betrayed the people it claimed to be representing.
While Mr. Zuma remained popular in many areas that were economically dependent on the party and public works, he was deeply unpopular in Gauteng, the province that includes Johannesburg and Pretoria, where the black middle class is concentrated.
Still, though mocked by the country’s black elite, Mr. Zuma was the most gifted politician in townships and rural areas, where he tapped into the resentment of those left behind. He excited crowds by dancing, delivering speeches in English and Zulu, and often performing a song by the A.N.C.’s former military wing, “Bring Me My Machine Gun.”
Problems in his private life spilled out often into public view. In 2006, Mr. Zuma was found not guilty of raping a 31-year-old family friend. He testified in court that she had seduced him by wearing a short skirt. He also said he had taken a shower afterward to minimize the risk of contracting H.I.V.
A polygamist under Zulu tradition, Mr. Zuma has more than 20 children, some of whom have been involved in questionable business deals.
Throughout his time in office, corruption flourished, especially at the state enterprises where access was given to family, friends and business associates, including the Guptas, a wealthy family with widespread business interests.
He appointed loyalists — sometimes with little experience — to his cabinet and to top positions at state companies like Eskom, the power utility, and South African Airways, the national carrier.
In a 2016 report on corruption, Thulisile Madonsela, the former public protector, described widespread influence-peddling in the Zuma administration and called for a public inquiry. After failing to quash the investigation in the courts, Mr. Zuma recently announced the appointment of a commission of inquiry.
Mr. Zuma spent his adult life in Africa’s oldest and most famous liberation party, serving as the party’s intelligence chief during the anti-apartheid struggle. He succeeded in becoming president despite a string of problems that would have ended the careers of less skilled politicians.
He faced charges of corruption in an arms deal in the 1990s when he was a senior party leader. He has avoided prosecution in the case, but state prosecutors are expected to decide this month whether to indict him on corruption charges.
Mr. Zuma often said critics exaggerated the level of graft in his administration. In his last speech as party leader in December, he said the party needed to be protected from “corporate greed” and attacked the country’s white-dominated business community.
“Theft and corruption in the private sector is as bad as that in government,” he said.
But the case that perhaps angered most South Africans was related to the improvements to Mr. Zuma’s homestead in Nkandla, in KwaZulu Natal Province.
Mr. Zuma said that the upgrades, including a swimming pool and chicken coop, were necessary to ensure his safety and that the costs should therefore be borne by taxpayers. In Parliament, he mocked opposition lawmakers’ pronunciation of Nkandla and cackled openly, secure in his party’s overwhelming majority.
The Public Protector’s office rejected the president’s claims and ordered him to reimburse the state. Mr. Zuma refused, leading the nation’s highest court to rule that he had acted unconstitutionally by disregarding the Public Protector.
Mr. Zuma eventually paid the government the $650,000 — about 7.8 million rand — but his intransigence led to further legal problems.
The nation’s highest court ruled in December that the A.N.C.-dominated Parliament had not properly investigated Mr. Zuma’s conduct in the Nkandla case when it defeated an opposition-led effort to impeach him in 2016.
The court ordered lawmakers to create rules to regulate a president’s impeachment, raising the possibility that a sitting Mr. Zuma would have faced proceedings this year.
The Nkandla affair turned many loyal voters against the A.N.C. in local elections in 2016. For the first time, many urban middle-class black voters stayed home or jumped to the opposition at the ballot box, as the party lost control over the nation’s biggest cities.
Even with their rural strongholds, A.N.C. leaders worried that the party might garner less than half the vote in national elections in 2019, forcing it to take on a coalition partner to govern, or lose power outright.
“We don’t want to be relegated to a rural party,” Gwede Mantashe, the A.N.C.’s national chairman, said during the election for party leader in December. “We want to regain the metros and be a strong A.N.C.”
Mr. Mantashe is an ally of Mr. Ramaphosa, who is backed by business and whose core supporters include educated, middle-class black South Africans.
Mr. Zuma probably realized the end was near when Mr. Ramaphosa defeated Nkosazana Dlamini-Zuma, Mr. Zuma’s preferred candidate and his former wife, in the election in December. As the results were announced in a large convention hall in Johannesburg, Mr. Zuma, famous for his joviality and charisma before crowds, sat stone-faced and bit his lips.
It took less than two months for Mr. Ramaphosa and his allies to win over fence-sitters and recalcitrant members of the Zuma camp. For all of Mr. Zuma’s skills as a strategist, he was a lame-duck leader battling the future as embodied in Mr. Ramaphosa and the new leader’s power over appointments and patronage.
Mr. Zuma was well acquainted with the dangers of what South Africans call the two centers of power: the year and a half during which the nation and the all-powerful A.N.C. are headed by different people. After being elected A.N.C. leader in 2007, Mr. Zuma himself orchestrated the early exit of his rival Mr. Mbeki as South Africa’s president.
In pressing Mr. Zuma to step down, Mr. Ramaphosa’s allies argued that the new leader should take over the government as soon as possible to rebuild the A.N.C.’s reputation and brand before the 2019 elections. The longer Mr. Zuma remained in power, they said, the greater the risk of performing poorly next year.
The party that had always shielded Mr. Zuma agreed.