South African players celebrating their qualification
Hosts South Africa finished top of Group A after their dramatic 2-2 draw with Morocco in Durban knocked the North Africans out of the tournament.
Knowing a win would take them through, Morocco twice led - only to exit the finals, as Cape Verde beat Angola 2-1.
After Issam El Adoua headed home 10 minutes in, May Mahlangu curled home in fine style after 71 minutes.
Mehdi Namli put Morocco in front again but Siyabonga Sangweni broke North African hearts with a late equaliser.