South Africa qualified for the Olympic Games for the third time after defeating Ghana 6-5 on penalties following a 2-2 draw in the third-place play-off match at the U23 Africa Cup of Nations on Friday.
David Notoane's men came into this match wounded having lost 3-0 to tournament hosts Egypt in the semi-finals on Tuesday.
While the Black Meteors were looking to bounce back to winning ways after losing to their West African rivals Ivory Coast on penalties in midweek after another 2-2 draw.
Ghana started the match brightly as they looked to grab an early lead, but South Africa looked solid and compact at the back.
The Southern Africans grew in confidence as the match progressed and they managed to break the deadlock.
Black Meteors defender Habib Mohamed scored an own-goal when he deflected Luther Singh's effort into the back of the net to make it 1-0 to South Africa in the 15th minute.
Singh was looking lively for Notoane's side and he forced Ghana goalkeeper Kwame Baah into a top save as South Africa looked to double their lead.
The score was 1-0 to South Africa at the half-time interval following a lively first half in the Egyptian capital of Cairo.
Ghana came back rejuvenated following their half-time team talk with their coach Ibrahim Tanko and they grabbbed an early goal in the second half.
Evans Mensah beat South Africa goalkeeper Mondli Mpoto with a thunderous effort to make it 1-1 for the Black Meteors in the 50th minute.
Former Cape Town Santos striker Notoane reacted by introducing Kamohelo Mahlatsi as South Africa looked to restore their lead.
The 21-year-old attacker made an immediate impact as he beat Baah with a shot from inside the box to make it 2-1 to South Africa two minutes after the hour-mark.
The momentum was with Ghana in the closing stages of the match as Issah Abass hit the crossbar, before Mensah placed his effort narrowly wide of the target.
The Black Meteors' late pressure paid off when Samuel Obeng netted in the 85th minute to ensure that the game ended in a 2-2 draw and a penalty shootout followed.
South Africa went on to book their place in the 2022 Olympic Games which will be hosted by Tokyo in Japan after winning 6-5 on penalties, while Ghana failed to qualify for the global competition.