South Africa's ruling ANC suffered its worst electoral results since the end of apartheid.