In the game played on the penultimate day of the competition held in Niamey, play at regulation time ended goalless.
The News Agency of Nigeria (NAN) reports that it was the first time South Africa finished third in the history of the competition after two fourth-place feats in 2009 and 2017.
Siphesihle Mkhize who scored South Africa’s first goal in the tournament netted the decisive spot kick to earn the Amajita a crucial win.
It was the third time that seven-times champions Nigeria finished fourth in the competition.
The Flying Eagles finished fourth in 1979 and in 1981.
Both teams had earlier played out a goalless draw in their second Group A match at the competition.
Paul Aigbogun made five changes to the side that lost 4-3 on penalty kicks to Mali in the semi-finals on Wednesday after regulation time scoreline ended 1-1.
Olawale Oremade, Utin Ikuowen, Yahaya Nafizi, Aniekeme Okon and Ibrahim Aliyu were dropped for Detan Ogundare, Mike Zaruma, Peter Eletu Igor Ogbu and Paschal Onyekachi.
The Flying Eagles started off slowly and, in spite of having more possession of the ball, failed to create a clear-cut chance before the interval.
Eight minutes into the second half, Aigbogun hurled off Peter Eletu for Abubakar Ibrahim as he went in search of goals.
Effiom Maxwell came close to breaking the deadlock in the 65th minute with an overhead kick but his shot was saved by the South African goalkeeper.
As the Flying Eagles kept the pressure on, the former Warri Wolves and Enyimba coach also introduced Nazifi Yahaya with nine minutes left to play.
But it was South Africa who had a chance to score with a fast break, even though they could not string the right passes, only forcing a save from Ogundare in goal for Nigeria.
During the penalty kicks shootout, South Africa scored all their kicks, while Jamil Muhammad, Maxwell Effiom and Zaruma scored for Nigeria, and Ibrahim Alhassan missed.(NAN)