South Africa's ANC was on track for its worst electoral performance since the end of apartheid on Friday as voters vented anger about high unemployment and corruption in municipal elections that herald a sea change in politics and society.
The African National Congress has ruled virtually unopposed since it ended white-minority rule in 1994 with Nelson Mandela at its helm, but has lost support - particularly in cities - among voters who feel their lives have not improved and accuse President Jacob Zuma of mismanaging the economy.
The ANC was still leading in the overall count in the nationwide municipal vote, with 95 percent of ballots counted. But it lost to the main opposition Democratic Alliance (DA) in the municipality of Nelson Mandela Bay, which includes the city of Port Elizabeth.
The DA was also narrowly ahead in the economic hub of Johannesburg, and the two parties were on par in Tshwane, home to the capital Pretoria.
Since the end of apartheid, the ANC had enjoyed an iron electoral grip on these areas.
Now, no party looks likely to win a majority in these three urban centers, ushering in a new era of coalition politics as South Africa shifts from what has effectively been a one-party system in the period immediately post-apartheid.
This shift reshapes the political landscape in South Africa ahead of the 2019 national election, and may also embolden Zuma's rivals within the ANC to challenge him.
The DA has retained control of Cape Town, which it has held since 2006.
Deputy President Cyril Ramaphosa said the party would do some soul searching, acknowledging that some critics had called the ANC "arrogant, self-centred, self-serving", but saying those descriptions were unfair.
"We've lost Nelson Mandela Bay, we've conceded that we've lost it, and we are going to do an introspective look at ourselves... we are a party that is not going away," he said.
The election also represents a political renaissance for the DA, which last year elected its first black leader, Mmusi Maimane, as part of its efforts to shake off its image as a party that mainly serves white interests. The party has its roots in the Progressive Party led by liberal whites who campaigned against apartheid during the era of white rule.
"I'm quite glad to announce the fact that, here in the city of Tshwane, by all of our current projections, certainly we will be the largest party," Maimane said, although the two parties were by that point neck and neck there, at just over 42 percent each, with 82 percent of the votes counted.
Final results are due on Saturday.
The ANC has lost its grip on the major cities where millions of black people are now looking beyond its liberation struggle credentials and focusing on weak growth prospects for an economy teetering on the edge of a recession.
Voters, facing a lack of jobs and poor basic services, have been incensed by a string of corruption scandals that have engulfed Zuma.
"In many respects the elections were exactly about national issues, national policy failures and poor national leadership as much as they were about local issues and local problems," said Gary van Staden, political analyst with NKC African Economics.
The radical leftist Economic Freedom Fighters (EFF) party, which is led by Julius Malema, Zuma's one-time protege, is participating in only its second election and was running a distant third in the votes counted.
It has, however, won some support from voters frustrated about inequality in a country where black people make up about 80 percent of the 54 million population, yet most land and companies remain in the hands of whites, who account for about 8 percent of the population.
Malema plans to nationalize banks and land, and redistribute among poor black people wealth still mostly in white hands -policies that both the DA and the ANC have not found palatable.
But neck-and-neck races between the ANC and DA in Johannesburg and Tshwane mean the EFF's 10 percent share of the vote could be needed for coalitions there.
"We will wait for those who are interested to approach us and then we will take the discussion from there," Malema told reporters.
Voters are losing patience with Zuma, who rattled investors in December by changing finance ministers twice in a week, sending the rand currency plummeting.
The president survived an impeachment vote in April after the Constitutional Court said he breached the law by ignoring an order to repay some of $16 million in state funds spent on renovating his private home. Zuma has since said he will repay some of the money.
Ratings agency Fitch said in a statement that although the results may weaken Zuma, the president has built a strong network of support in the ANC's upper echelons "and there have been no clear signs that a majority of leaders could withdraw their support before the ANC conference in December 2017."
The party is due to meet then to pick Zuma's successor as party leader, who would become South Africa's president should the ANC continue its unbroken string of victories in the 2019 election.
The rand held its ground close to a nine-month high against the dollar early on Friday, partly boosted by the smooth running of the elections.
"Foreign investors will probably welcome the fact that reduced support for the ruling ANC has helped the centrist DA rather than the leftist EFF," said John Ashbourne, Africa analyst at Capital Economics, in a note.