Want smart analysis of the most important news in your inbox every weekday along with other global reads, interesting ideas and opinions to know? Sign up for the Today’s WorldView newsletter.

A quarter-century after the African National Congress first took control of South Africa’s government, the political party managed to come out on top in general elections last week, securing its hold on power — at least for now.

But the narrow margin of the historic party’s win also reflected a long-brewing discontent with South Africa’s political sphere.

The ANC took home only 57.5 percent of the vote — a sign of growing distrust in its leadership, which has suffered scandal after scandal in recent years. This was the first time that the ANC won less than 60 percent of the vote in a general election, making the results both a win and a loss for the party, which has struggled to excite voters in the wake of widespread corruption allegations.

Despite the scandals, a large number of South Africans still expressed loyalty to the ANC, the party that guided the country into the post-apartheid era in 1994 with Nelson Mandela at its helm. But others expressed a lack of interest in supporting the ANC or the political process, and voter turnout plummeted from 73 percent in 2014 to 65 percent this year. Many of those who stayed home from the polls were young people, members of what has become known as the “born-free generation,” a nickname for South Africans who were raised post-apartheid. On social media, some shared their reasons for staying home using the hashtag #IWantToVoteBut, citing empty campaign promises and widespread unemployment.

“The political parties all have one thing in common: They make lots of promises, and they break all of them,” one 23-year-old told my colleague Max Bearak in Soweto, a massive township outside Johannesburg.

South African President Cyril Ramaphosa took office last year after legal woes and corruption allegations led his predecessor, Jacob Zuma, to step down after nearly a decade in power. The National Assembly voted for Ramaphosa to replace him, and his party’s win last week means he can carry out a full five-year presidential term.

Ramaphosa has branded himself as the ANC’s cleanup act, seeking to repair the party’s image after its reputation suffered a major blow under Zuma’s leadership.

And Ramaphosa seemed intent on doubling down on his anti-corruption rhetoric after election results were announced Saturday. On Sunday, he told a crowd of supporters in Johannesburg that he would rid the ANC of “bad and deviant tendencies” and would not offer positions of power to anyone who intended “to fill their own pockets.”

But he has a lot of work ahead of him if he wants to save the ANC from further collapse.

As South African journalist Natasha Marrian put it in the Mail and Guardian last week, the ANC “has been allowed to corrode and rot for the past two decades, and its very survival depends on it being able to fix itself, fast.”

Distrust of the ANC establishment has been building for years. Zuma, a long-standing political figure in South Africa, faced worrying allegations even before he became president in 2009. Like Mandela, Zuma was a political prisoner as a young man, and he was once thought of as a hero in South Africa’s liberation movement. But as time went on, he gained a reputation for malfeasance.

Before his election, he was accused both of raping a family friend and being linked to a corrupt arms deal in the 1990s. He was acquitted in the rape case, and the corruption case was dropped before his 2009 election, but the arms deal continued to haunt him well into his presidency.

While in office, he was accused of using state money to finance unnecessary upgrades to his private residence, a major embarrassment for the ANC, and of colluding with the wealthy Gupta family. He now faces 18 charges of corruption, as a South African judicial commission investigates his ties to the Guptas. Even so, some within the ANC still support Zuma, paving the way for political infighting.

When it came to the election results, however, Ralph Mathekga, a South African writer and political commentator, told The Washington Post that Ramaphosa hit a “sweet spot” in separating himself from Zuma and the party’s shortcomings.

“The blame still goes to Zuma, and Ramaphosa avoids being the first ANC leader to lose a majority,” Mathekga said.

But Ramaphosa’s anti-corruption push wasn’t enough to win the hearts and minds of all South Africans. Journalist Lynsey Chutel wrote in Quartz over the weekend that “Ramaphosa’s focus on land redistribution and anti-corruption did not quite yield the results the party had hoped.”

And some observers cast doubt on Ramaphosa’s ability to turn the country around, accusing supporters of over-investing in his promises to rebuild democratic institutions. As Bearak reported before the election, South Africa’s economy has suffered significantly in recent years, and Ramaphosa’s promises to turn it around have not materialized, even as he branded himself as a candidate who will bring change.

Writing for Foreign Policy before the vote, South African political analyst Eusebius McKaiser called South Africa the “trough from which looters within the halls of power have eaten gluttonously for at least the past decade” and said the state “lacks the capacity to simply get back to the business of good governance the morning after the election results are announced.”

But Rampahosa seems determined to try. In his remarks in Johannesburg on Sunday, he promised to weed out graft and exploitation. “We are going to end corruption whether they like it or not,” he said.

Want smart analysis of the most important news in your inbox every weekday along with other global reads, interesting ideas and opinions to know? Sign up for the Today’s WorldView newsletter.