By TJ Strydom

PRETORIA (Reuters) - South Africa's ruling African National Congress (ANC) party took an early lead on Thursday as vote counting continued in local government elections where it faces the risk of losing control of key cities for the first time since coming to power.

The party, which toppled white apartheid rule after the country's first democratic elections in 1994, is up against its stiffest electoral challenge to date against the backdrop of high unemployment, a stagnant economy and controversies surrounding President Jacob Zuma.

With 5 percent of the votes in so far, the ANC held a 54 percent lead, against 33 percent for the Democratic Alliance (DA) and 5 percent for the Economic Freedom Fighters, which is participating in only its second election.

The ANC won 62 percent in the last municipal elections in 2011 while the DA garnered 24 percent.

Vote tallies are expected to trickle in throughout the day on Thursday, but the final national results are not expected before Friday.

A significant loss of support for Nelson Mandela's ANC, which led South Africa's decades-long struggle against oppressive white minority rule, would be a blow ahead of the next major test - the 2019 national elections.

Opinion polls see a particularly close race in the capital Pretoria as well as the country's economic hub, Johannesburg, and the symbolic Nelson Mandela Bay municipality named after the anti-apartheid icon.

The DA is expected to maintain control of Cape Town, the only big city not run by the ANC. The DA is a historically white-dominated movement hoping to expand support under its new black leader Mmusi Maimane.

"I voted DA because I'm sick of the rotten, corrupt ANC," said Simpiwe, an unemployed 55-year-old surrounded by shacks in a rundown Nelson Mandela Bay township on the southeast coast, after casting his ballot on Wednesday.

Many South Africans who queued up to vote said they were worried about Zuma's performance and the state of Africa's most industrialised economy, where only one in four in the labour force is unemployed.

Senzo Makhubela, a 32-year-old security guard, said the ANC needed to build more houses and do more to develop areas like Diepsloot, the shantytown where he lives north of Johannesburg.

But he was sticking with the ruling party for now, despite the travails of its leader. "Zuma doesn't make decisions alone so the ANC is not Zuma alone, it's a collective," he said.

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 December, he rattled investors after changing his finance minister twice in a week, sending the rand plummeting. The currency has since recovered.

Zuma has said he would repay some of the funds spent on his home and rejected criticism of his conduct, but anger is rising in a country on the brink of recession.

Analysts also predict a downgrade by credit ratings agencies to "junk" status.

"A very weak outcome for the ANC, getting less than a 55 percent national vote share and losing three metros, would likely be viewed as a market positive," said Nomura emerging market analyst Peter Attard Montalto.

(Additional reporting by Nqobile Dludla in Pretoria, Mfuneko Toyana and Tanisha Heiberg in Johannesburg, Siphiwe Sibeko in Limpopo, Joe Brock in Port Elizabeth and Wendell Roelf in Cape Town, writing by Stella Mapenzauswa, editing by G Crosse)