An election poster of the United Democratic Movement is attached to a pole next to washed clothes in Cape Town. (Rodger Bosch/AFP/Getty Images)

Urban South Africans on Thursday dealt the African National Congress its biggest political blow since the end of apartheid, knocking the ruling party off its perch in three cities as voters vented anger at corruption, high unemployment and poor public services.

The ANC, which ended white minority rule when it won power in the first democratic national election in 1994, still held a big lead in the overall count in nationwide municipal elections. But it was trailing the opposition Democratic Alliance in Port Elizabeth, which it has held virtually unopposed for the past two decades. The ANC was also unlikely to make it to 50 percent of the vote in the capital of Pretoria and the economic hub of Johannesburg.

A significant loss of support for the ruling party in these areas could mark a watershed in South African society and politics as the country shifts from what has effectively been a one-party system in the era immediately after apartheid. It could reshape the political landscape ahead of the 2019 national election and may also embolden President Jacob Zuma’s rivals within the ANC to challenge him.

The municipal vote comes as Africa’s most industrialized country teeters on the edge of a recession after a string of corruption scandals surrounding Zuma.

The ANC failed to win Zuma’s home town of Nkandla in ­KwaZulu-Natal province, where the Inkatha Freedom Party retained its hold on the region.

South African voters queue outside a polling station outside a former hostel complex in KwaMashu, north of Durban, on August 3, 2016. (Marco Longari/AFP/Getty Images)

Many ANC supporters are switching allegiances to the Democratic Alliance, bolstering its attempts to attract black voters and shake off its image as a party that chiefly serves the interests of the white community.

With 85 percent of the vote counted, the ANC led in the national count with 53.5 percent, against 27.5 percent for the Democratic Alliance and 7.5 percent for the left-wing Economic Freedom Fighters. Final results are expected by Friday.

The Democratic Alliance, which last year elected its first black leader, Mmusi Maimane, was ahead in Johannesburg and in Nelson Mandela Bay, the area named after the anti-apartheid hero who led the ANC to power. It includes the city of Port Elizabeth. The Democratic Alliance had an unassailable lead, almost 69 percent of the vote, in Cape Town, the only big city not run by the ANC.

The ANC was dominating most of the countryside, long a key area of its support, underscoring a widening political divide between urban and rural South ­Africa.

“The ANC vote has held up well in rural areas but fallen away sharpest in urban areas, as expected. The ANC is therefore becoming a party of the rural vote,” said Nomura analyst Peter Attard Montalto.

The Economic Freedom Fighters, led by Julius Malema, Zuma’s onetime protege and a former ANC youth leader, is participating in only its second election and was running a distant third in votes counted.

Many South Africans who lined up to vote across the country on Wednesday said they were worried about Zuma’s performance and the state of the economy. Zuma survived an impeachment vote in April after the Constitutional Court said he breached the law by ignoring an order to repay some of the $16 million in state funds spent on renovating his private home in Nkandla.