Mokoena, a late arrival for the eight-nation competition because SuperSport United refused to free him ahead of the November 10-19 international window, struck on 79 minutes.
The free-kick was in the middle of the pitch, but well outside the penalty area, and Mokoena lifted the ball over a wall of players and goalkeeper Ira Tape Eliezer.
Victory lifted South Africa to the top of Group B with four points, one more than the Ivory Coast and Nigeria, who defeated Zambia 3-1 in the second match of a double-header.
In a wide open group with one round to play this Friday, bottom team Zambia can still qualify while South Africa might miss out on a top-two finish and a semi-finals place.
Zambia, who have only one point, face the Ivory Coast and South Africa meet Nigeria in matches that will be played simultaneously at the Al Salam and Cairo International stadiums.
Success was particularly sweet for the South Africans as they arrived in Egypt last week with only 12 players for a tournament which doubles as the Africa U23 Cup of Nations.
- 'A disgrace' -
By the time they played Zambia the squad have grown to 15, six players short of the permitted number, as some domestic and European clubs refused to free players before the FIFA window.
"It is a disgrace," said South African football legend Neil Tovey, who captained his country to victory in the 1996 Africa Cup of Nations.
"It is downright diabolical that they cannot have the best players. This is a sad state of affairs -- begging clubs for players."
Nigeria needed 93 minutes to seal victory over Zambia and keep alive hopes of an eighth appearance at the Olympics, where they won gold in 1996 and silver in 2008.
Zambia goalkeeper Mangani Banda raced out of his area to clear in stoppage time, but Taiwo Awoniyi got to the ball first and his angled shot trickled into the net.
Patson Daka had given Zambia an early lead that Orji Okwonkwo swiftly cancelled and Kelechi Nwakali, once on the books of Arsenal, nudged Nigeria ahead off a second-half free-kick.
On Thursday, already-qualified Group A leaders Egypt tackle second-place Cameroon while Ghana must defeat Mali to have any chance of finishing runners-up.
The top three finishers in Egypt will represent Africa in the 16-nation Tokyo football tournament.