By Dinky Mkhize

PRETORIA (Reuters) - South African police said on Wednesday that two suspected looters had been shot dead in the capital in violence triggered by the ruling party's choice of a mayoral candidate for local polls.

Police said they also arrested 40 rioters who had been attacking foreigners' shops as public anger mounted over economic hardship in the build-up to Aug. 3 elections likely to become a referendum on President Jacob Zuma's leadership.

Residents of Pretoria's townships began setting cars and buses alight on Monday night after the ruling African National Congress (ANC) named a candidate in the Tshwane municipality where the capital city is located, overruling the choice of regional branches. Burned-out cars still blocked roads on Wednesday.

The two killed were shot on Tuesday night, said Colonel Noxolo Kweza, police spokeswoman for Gauteng Province. She did not say who had shot them.

"Two of the suspects were shot and killed following looting at Mamelodi," police said in a statement, adding that those arrested would face charges of violence and theft.

"Incidents of protests and looting continued in other areas while situation is tense in others."

Violence continued in parts of the capital on Wednesday.

"Some of the areas are tense but quiet for now, while in other areas there is still some unrest, there are reports of protests and incidents of looting," Kweza said.

"We will have strong police presence tonight, as we have had during the other nights."

Protesters continued to clash with police and "a disproportionate part of the looting was taking place at shops owned by foreign nationals," Tshwane Metro police spokesman Console Tleane told eNCA television.

Foreigners, many of them from other African countries, suffered a wave of attacks in April last year, by crowds blaming them for taking jobs and business.

ANC "LOSING TOUCH"

The mayoral dispute flared on Sunday when an ANC member was shot dead as party factions met to decide on a candidate for mayor of Pretoria's Tshwane municipality.

The ANC leadership then named senior party member and former cabinet minister Thoko Didiza as its candidate for Tshwane, overriding regional branch members and refusing to back down as the violence mounted.

The ANC said it picked the candidate as a compromise between two rival factions in Tshwane. But critics say the decision by the party, which has been in power since the end of white-minority rule in 1994, showed that it is losing its touch in areas - including Pretoria - where it was once unassailable.

A meeting by the party due to be held on Wednesday to discuss the crisis was postponed, an ANC regional official Lesego Makhubela told EWN online news service.

Analysts warned of more unrest in Gauteng province, which includes Pretoria and Johannesburg.

"Intra-ANC, election-related, factional violence is being ignored by markets trading on external factors, but is worrying," London-based Nomura emerging markets analyst Peter Attard Montalto said in a note.

Zuma survived impeachment in April after the Constitutional Court ruled he had breached the constitution by ignoring an order from the anti-graft watchdog to repay some of the $16 million in state funds spent renovating his home.

"Ahead of the August elections, disgruntled ANC supporters in Gauteng will be motivated by the Pretoria riots to stage further protests to demonstrate the unpopular ANC leadership's decisions," Robert Besseling, head of the EXX Africa business risk intelligence group, said in a note.

(Additional reporting and writing by James Macharia; editing by Andrew Roche)