The African National Congress lost its grip on local government in Tshwane, home of South Africa's capital Pretoria, as results on Saturday gave the opposition Democratic Alliance a second big win in the ANC's worst election since the end of apartheid.
As final votes were counted, the ANC was leading in economic powerhouse Johannesburg by a slim margin. But as well as defeat in Tshwane it lost Nelson Mandela Bay, which includes manufacturing hub Port Elizabeth, to the DA.
The results have reshaped the political landscape in South Africa where the ANC has ruled virtually unopposed since it ended white-minority rule in 1994, led by Nelson Mandela.
But unemployment, a stagnating economy and scandals around President Jacob Zuma led voters to punish the ANC, changing the outlook for national elections in 2019 and potentially emboldening Zuma's rivals within the ANC to challenge him.
With 99 percent of votes counted from Wednesday's local elections, the ANC was leading with the most votes overall and said it would still try to form coalitions to govern the municipalities where it lost its majority.
The DA, which fell short of a majority in both Tshwane and Nelson Mandela Bay, would also need to form coalitions to take power in those areas.
But the results mark a watershed for the DA which last year elected its first black leader, Mmusi Maimane, as it tries to shake off an image as a party mainly serving white interests. The party held Cape Town which it has controlled since 2006.
"It signals to everyone that the tide in our country is turning," Maimane told reporters on Saturday.
Paul Mashatile, the ANC chairman in Gauteng province, which includes Tshwane and Johannesburg, said: "We can confirm that we are into (coalition) negotiations as we speak."
He blamed the poor result on low voter turnout by ANC supporters countrywide.
"It's quite clear that our people, our traditional supporters, are still with us but maybe not too many people came out to vote so we need to go back and find out why."
The ANC has lost support among voters who feel their lives have not improved and the opposition has accused Zuma of mismanaging the economy. Millions of urban voters are now looking beyond its liberation struggle credentials and focusing on an economy teetering on the edge of a recession.
Zuma rattled investors in December by changing finance ministers twice in a week, sending the rand plummeting. The currency has since recovered and received a boost from the lack of violence during the local elections.
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 as ordered by the court.
"The ANC may just become a rural party," said William Gumede, head of the Democracy Works Foundation think-tank.
The radical leftist Economic Freedom Fighters (EFF) party led by Julius Malema, Zuma's one-time protege but now arch-foe, came a distant third in the local elections, with about 10 percent of the vote.
Malema has drawn support with promises to nationalise 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.
With the ANC and DA both seeking to rule in Johannesburg and Tshwane, the EFF could be courted where coalitions are needed.
Malema has not said whom he would back, saying: "If anyone comes to us, we'll talk."