South Africa beat Rwanda 3-0 in Nelspruit to finish first in Group C as Benin, who had a two-point lead going into the final round of fixtures, tumbled from top place to third in the standings as they lost 4-0 to the Super Eagles in Uyo.
South Africa finished on 18 points, with Nigeria runners up ahead of Benin on goal difference as both ended with 17 points.
The folly of fielding a defaulter in March will now be largely forgotten as South Africa qualified for the first time since hosting the 2010 finals.
Thalente Mbatha scored after five minutes, and Oswin Appollis netted the second in the 21st minute to put Bafana on their way.
Striker Evidence Makgopa made it 3-0 in the 72nd minute with a header from a corner as all goals came from Orlando Pirates players.
It all started brightly for Bafana, who had made four changes to the line-up from the side that was held goalless by Zimbabwe in Durban on Friday.
Thalente Mbatha was one of those changes and repaid the faith of the coach Hugo Broos with a fifth-minute strike.
It was one of his trademark long-range shots, which had previously got South Africa out of trouble in last year’s Africa Cup of Nations qualifiers.
He was cued up by Appollis, again dangerous on the right but indecisive with his final touch. Mbatha looked at first, when he received the pass, like he was going to circulate the ball but then had a change of heart, a touch and blasted a shot that Rwanda goalkeeper Fiacre Ntwari tried to palm away but it was so hard it forced his hands back as the ball flew into the net.
By that time, Nigeria had taken a 1-0 lead over Benin in Uyo through Victor Osimhen, and so South Africa were already World Cup-bound within five minutes of kick-off.
Ntwari denied Appollis from close in the 12th minute, and Teboho Mokoena should have made it 2-0 from the resultant corner, miscuing his header with an empty goal yawning before him.
Appollis then thrashed home Bafana’s second goal in the 21st minute to settle nerves and get the meagre crowd at the stadium further involved.
Thapelo Morena’s square pass found Makgopa, who cut past one defender, but before he could go any further, Appollis took the ball off his feet and thrashed it home.
Morena had to go off injured before half-time, in tears as he limped away, to be replaced by Mohau Nkota, who had been dropped after the Zimbabwe clash.
Appollis missed an easy chance in the 61st minute after a strong run from Aubrey Modiba down the left flank pulled it back for him in the small box, but Appollis rushed the effort and did not connect.
Khuliso Mudau’s rasping shot went wide five minutes later when it looked easier to score. Mudau has previous in terms of missing the target for Bafana, as he cost the team a place in the last Africa Cup of Nations final.
When Sipho Mbule’s shot was deflected for a corner, Appollis took the set piece and Makgopa, playing because Lyle Foster was injured, headed home the third.
Rwanda’s Abedi Biramahire struck the Bafana woodwork with a thundering long-range effort with eight minutes left, but as it hit bounced back into play, it was all too evident that Bafana’s luck was well and truly in.