Updated

South Africa's main opposition party says it has agreed with several smaller parties to build governing coalitions in some municipalities following elections in which the ruling African National Congress suffered its worst setback since taking power.

The announcement Wednesday by Mmusi Maimane, leader of the Democratic Alliance, solidifies the party's electoral gains at the expense of the ANC, which has ruled since the end of apartheid in 1994.

The ANC won the most votes in Johannesburg but lost out to the Democratic Alliance in the capital, Pretoria, and its surrounding Tshwane metropolitan area. It also lost in a coastal metro area called Nelson Mandela Bay.

But neither party won more than 50 percent of the vote in those areas, meaning they could not govern alone.