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.