South Africa's ruling party the African National Congress (ANC) has lost the metropolitan area which includes the capital in its biggest election setback since it took power 22 years ago.
In the municipal elections, the opposition Democratic Alliance party edged out the ANC in Tshwane, though it did not win a majority, raising the likelihood of a coalition government.
With less than 1% of votes left to be counted, the race for the country's largest city, Johannesburg, remains too close to call.
Final results are being announced at roughly 5pm Irish time.
Since South Africa's first all-race election in 1994, the ANC has had widespread support on the strength of its successful fight against white-minority rule.
This time, it has been challenged by corruption scandals and a stagnant economy that has frustrated the urban middle class, while protests in poor communities demanding basics like electricity and water have been common.
On social media, South Africans mocked president Jacob Zuma's recent claim that the ANC would rule "until Jesus comes back".
The ANC has also lost its first major black-majority municipality in this election, Nelson Mandela Bay, named after the ANC's star and the country's first black president.
The Democratic Alliance, which has roots in the anti-apartheid movement and had a white party leader until last year, won Nelson Mandela Bay after fielding a white candidate for mayor.
The party already runs the country's second largest city, Cape Town, the only major South African city where blacks are in the minority among white and mixed-race residents.
It has been pushing hard to win supporters in other regions, saying its brand is good governance.
The party's leader, 36-year-old Mmusi Maimane, had predicted victory in Tshwane.
"For far too long, the ANC has governed South Africa with absolute impunity," Mr Maimane told reporters.
He said the idea that his party was a white one has been "completely shattered".
The Democratic Alliance angered the ANC last month by declaring that it was the only party that could realise Mr Mandela's dream of a "prosperous, united and non-racial South Africa".
Mr Maimane immediately looked ahead to presidential elections, declaring: "The 2019 campaign starts now."
The ANC so far has received 53% of votes across the country, its lowest percentage ever, with the Democratic Alliance getting 26%.
A more radical opposition party, the Economic Freedom Fighters, contested the local elections for the first time and received 8% of the vote nationwide after promising measures it says will help the poor.
The results for the ANC could put pressure on the 74-year-old Mr Zuma to leave office before his mandate ends in 2019, political analysts said.
Mr Zuma's office said he would attend the announcement of the final election results.
The ANC has said "we will reflect and introspect where our support has dropped".
It retained support in many rural areas in a country where blacks make up 80% of the population.
The South African economy has stagnated since the global financial crisis in 2008, and the World Bank said the country has one of the highest rates of inequality in the world.
Scandals swirling around Mr Zuma have also hurt the ANC. Opposition groups have seized on the revelation that the state paid more than $20m for upgrades to Mr Zuma's private home.
The Constitutional Court recently said Mr Zuma violated the constitution and instructed him to reimburse the state $507,000.
Many South Africans are also concerned over allegations that Mr Zuma is heavily influenced by the Guptas, a wealthy business family of immigrants from India.
The president has denied any wrongdoing.