South Africa qualified for the semi-finals of the All Africa Games football tournament when beating Ghana 1-0 in Maputo on Wednesday.
Substitute Fisimpilo Ntombela grabbed the match-winner 11 minutes from time.
Having beaten hosts Mozambique 3-1 on Sunday, Shakes Mashaba's side qualified from the three-team group with maximum points from their opening matches.
On Saturday, Ghana and Mozambique go head-to-head for Group A's remaining semi-final spot.
Prior to the tournament, Ghana had been expecting to face Cameroon, Senegal and Uganda in Group B.
But the Ghanaians were moved to Group A after both Libya and Madagascar withdrew from the competition.
On Wedneday, Ghana should have taken the lead after 19 minutes but Prince Baffoe's snapshot flew well wide.
A minute later, Ahmed Sani wasted another good chance.
Late on, substitute Ntombela rewarded his coach when heading home a corner with his first touch just a minute after coming on.
"I'm happy that I was able to score with my first touch of the ball," said Ntombela, "but the important thing is that we are now in the semi-finals."
South Africa will have a week to prepare for their semi-final game, which will take place at Maputo's Machava Stadium next Tuesday
"It was a wake-up call for the players after the win over Mozambique as Ghana dominated us in the first half," said Mashaba. "But we made changes and the boys showed good character to turn it around."
In the women's event, Cameroon were the first team to qualify for the semi-finals after beating Algeria 3-0 at Maputo's Maxaquene Stadium.
The Cameroonians top Group A with six points, having beaten hosts Mozambique 1-0 in their opening game.
Ngachu Enow's side opened the scoring after Christine Manie converted a penalty awarded for handball after just five minutes.
Shortly after, Algeria were reduced to ten women when Habiba Sadou was dismissed for a second yellow card.
Cameroon wrapped up the points with goals from Iven Mihamle on the stroke of half-time and a late finish from Ariane Beyen.
The Indomitable Lionesses will not now play until Tuesday, when they will face the second-placed team from Group B in the semi-finals.
Mozambique's clash with the Algerians on Saturday will decide which team finishes second in the group to earn the other semi-final spot.