Andre Ayew’s late diving header secured Ghana a 2-1 win over South Africa and qualification to the Africa Cup of Nations quarter-finals as Group C winners.
Mandla Masango gave South Africa the lead in the 17th minute, when he smashed home past Ghana goalkeeper Razak Braimah from outside the box.
The Black Stars drew level in the 73rd minute through defender John Boye, whose drilled shot screamed under a diving goalkeeper Nhlanhla Khuzwayo.
Ayew then grabbed the winner in the 83rd minute through a diving header off a cross by Abdul Rahman Baba.
That left Ghana as Group C winners on six points with Algeria finishing second, also on six points after they beat Senegal 2-0 in the other game being played simultaneously in Malabo.
This was Ghana’s first win at the Nations Cup against Bafana Bafana after two defeats and a draw.
After a tentative start by both teams, Ghana threatened the South Africa goal twice in quick succession by the sixth minute.
First, a header by Jonathan Mensah off a Mubarak Wakaso free kick missed the target and moments later, South Africa goalkeeper Khuzwayo failed to hold on to a low drive, Jordan Ayew pounced on the rebound, but it was cleared off the line for a corner by Mathoho.
After South Africa went in front against the run of play, Ghana poured forward in search of an equalising goal.
A thunderbolt by Abdul Rahman Baba from outside the South Africa area in the 33rd minute was pushed away by goalkeeper Khuzwayo
Six minutes later, South Africa striker Bongani Ndulula forced goalkeeper Braimah to dive low and keep out his goal-bound header at the near post.
In the 48th minute, skipper Gyan’s free kick from a good position narrowly missed the mark as Ghana continued to attack in the hope of getting back into the game.
Seven minutes later it was the turn of Wakaso to force the goalkeeper to fumble his low shot drilled from distance for a corner. Celtic ace Wakaso again tried his luck from distance soon after, but again found no joy.
Ghana continued to pile on the pressure before they were rewarded in the 73rd minute through Boye and moments later, substitute Kwesi Appiah would have given the Black Stars the lead but his shot was turned away for a corner by the goalkeeper.
Their persistence eventually earned them the much-needed winner seven minutes from time and safe passage to the knockout rounds.