South Africa are closer to a semi-final spot at the Confederation of African Football Under-23 Africa Cup of Nations, after defeating Ivory Coast 1-0.
Having started their Group B campaign with a 0-0 draw against Zambia, a victory was essential for South Africa in Cairo, Egypt.
But Ivory Coast were top of the group following a 1-0 victory over Nigeria in their first game, so a tight contest was expected at Al Salam Stadium.
In a match of numerous chances, South Africa should have been ahead on 14 minutes.
Ivory Coast goalkeeper Eliezer Ira Tape was caught on the ball by Lyle Foster, but he somehow fired the ball wide of a gaping goal.
The Ivory Coast enjoyed a better second half, sending in numerous shots on goal and crosses into the box.
But it was South Africa's Teboho Mokoena who delivered the coup de grâce in the 79th minute, curling in a stunning long-range free-kick, sending their supporters into raptures.
In the other match in Group B, Nigeria beat Zambia 3-1, leaving them top of the standings.
The semi-finalists will be decided on Friday (November 15), with Nigeria playing South Africa and Ivory Coast up against Zambia - tomorrow is a rest day.
Three spots in the men's event at next year's Olympic Games in Tokyo are up for grabs at the tournament.
The finalists and the winner of the third-place play-off will qualify for Tokyo 2020.