Niger's goals came from Dankwa E Kofi and Moussa Maazou, before Andile Jali brought one back for Bafana.
The West Africans have jumped to the top of the standings on nine points, though South Africa and Sierra Leone (who beat Egypt 2-1 on Saturday) are still very much in the race to win the group with eight points apiece.
The hosts went 1-0 up in the opening minutes of the match, Kofi rising unmarked for a header from a corner.
Teko Modise had the best chances for South Africa in the first half, hitting the post twice; once early in the match and again, missing an open net, 10 minutes before half-time.
Bafana settled down after conceding early on, but looked to be struggling without the injured Katlego Mphela.
As half-time approached the wind picked up, cooling the heat somewhat, and Bafana looked more in control of the game.
Lehlohonolo Majoro was brought on for Thulani Serero at the beginning of the second half.
Bernard Parker blasted a shot over the bar just after the restart, after being set up by Siphiwe Tshabalala.
Then in the first few minutes of the second half Moussa Mazou scored from close range, after some poor defending by South Africa.
With 20 minutes to go Jali scored a fantastic goal to give South Africa a glimmer of hope, after some great teamwork in midfield.
But it was not enough, and the score remained 2-1, for Pitso Mosimane's first loss as coach of South Africa.
In the remaining Group G fixtures, Egypt play Niger at home and Bafana host Sierra Leone.
Niger are on nine points, Bafana and Sierra Leone on eight, and Egypt – who are out of the running – on two.
To finish top of the group Bafana must win their last match against Sierra Leone, and hope Niger either draw or lose against Egypt.
If we draw with Sierra Leone, and Egypt beat Niger, the top three teams will have nine points, and the placing will come down to goal difference.
As it stands Bafana have a goal difference of +2, Niger +1 and Sierra Leone 0.
The two best second-placed teams from all groups also qualify (apart from Group K, in which winner and runner-up qualify because of the late inclusion of Togo).
If South Africa lose to Sierra Leone, they will be eliminated from the competition.