Christantus Ejike opened the scoring in the 22nd minute, before Ifeanyi Ede scored the second -- from the penalty spot -- eight minutes later, sending the visitors into the half-time break with a comfortable lead.
Ejike put the result beyond doubt on 64 minutes to complete his brace and sent the host nation crashing out of the tournament at the first hurdle, despite Bernard Parker pulling one back in the 80th from a penalty.
Bafana coach Gordon Igesund made four changes from his team that drew 1-1 with Mali earlier in the week, most notably, Itumeleng Khune, who was ruled out due to injury and was replaced in goal by Moeneeb Josephs.
The hosts got off to a flying start and soon sent Parker through on goal, following a quick burst from Mbatha, who had the better of his man and sailed past the defence.
Parker cut back and hit his left-footed curled effort on target, but straight at goalkeeper Chigozie Agbim, who made a straightforward stop to deny Parker the opener, just five minutes into the group decider
Tshabalala was next to test Agbim minutes later, but the Kaizer Chiefs midfielder could not beat the shot-stopper, who made a second solid save, parrying away Tshabalala's well-hit effort from the set-piece.
South Africa looked lively in the middle of the field and chances opened up for Matthew Pattison and Thabo Nthethe, who rose above the Nigerian defence on 20 minutes and headed a powerful attempt at goal, but was thwarted by Agbim, who made another simple stop.
Against the run of play, however, Nigeria broke the deadlock through Ejike, who powered home a cross from Ifeanyi Ede, handing the Nigerians the vital lead midway through the opening half.
Things went from bad to worse for the home side on the half-hour mark, when Josephs' handling error led to him bringing down Ejike in the area, leaving referee Mohamed Benouza no choice but to award a penalty.
Ede stepped up confidently and belted the penalty into the bottom right of the goal, with Josephs getting a hand onto it, but failing to keep the shot out, as the Super Eagles extended their advantage in front of a stunned home crowd.
After the interval, Bafana looked to make a bright start, but soon Ede forced Josephs into a superb save after being left as the last man.
South Africa replied with a chance for Parker after an hour, but the striker's athletic attempt did little to trouble Agbim, after Parker had been put through on goal and should have passed across the face of goal for Bafana's oncoming numbers.
Mashego came agonisingly close a minute later with a snapshot from the edge of the area, but Agbim's fingertip save did enough to keep out the danger.
But like before, Nigeria soaked up the pressure and hit Bafana on the break, as Ejike emphatically netted his second of the night, leaving a dejected home side condemned to the worst.
With little to smile about for the home crowd, Solomon Kwambe's dismissal for a second yellow card gave Bafana a glimmer of hope 15 minutes from the end.
The numerical advantage lasted all of 60 seconds as right-back Vuyo Mere received his marching orders for a clumsy foul, for which he received his second yellow.
Having reached boiling point, tempers flared and on 80 minutes, Bafana were awarded a penalty of their own, after Mashego was brought down in the area.
Parker stepped up and scored his third successive spot kick to pull one back.
Agbim made a pair of decisive saves for the Nigerians as time ran out, denying Mashego and Tefu Mashamaite late goals and kept the Super Eagles' two-goal cushion intact.
It was not to be for Bafana, as Mali claimed a 2-1 win against Mozambique in the other game of the group, allowing Mali to qualify as the winners of group A with seven points, with Nigeria finishing second with six points.