Cyril Ramaphosa , who retained South Africa's presidency in national elections last week, faces a serious quandary. His party, the African National Congress — the party of Nelson Mandela, which has governed the country since the end of apartheid — has become profoundly corrupt, as any party would after 25 years of unchallenged power. Yet because of that same corruption, voters denied Mr. Ramaphosa the strong mandate he may need to cleanse the party and put South Africa back on track.

In his victory speech, Mr. Ramaphosa pledged to end corruption “whether some people like it or not.” Whether he can is the big question hanging over South Africa after the election. That he must try is not in question, nor is that at this stage he is the only leader who stands a chance of routing the deeply entrenched kleptocrats in the A.N.C.

The election results were the worst for the A.N.C. since it came to power in the heady days of 1994, flush from its victory over white minority rule. The party dipped below a symbolically significant 60 percent of the vote and barely held on to the critical province of Gauteng, home of Johannesburg and Pretoria, the economic and political capitals, and of the biggest concentration of black middle-class citizens. Equally telling, voter turnout fell to 66 percent from 73 percent in the last election, in 2014.

These may not seem like terrible figures by the standards of established democracies, but given the exalted history of the A.N.C., the vote marked a growing disillusionment with South Africa’s political system, especially among the young and the middle class. One reason is an unemployment rate that has only grown since the end of apartheid and now stands at a crippling 27 percent, in part because of the harmful policies of the last president, the infamous Jacob Zuma.