Obafemi Martins scored twice as Nigeria came from behind to beat Kenya 3-2 in Nairobi while Tunisia lost to a late goal in Mozambique after starting the final round of matches two points clear in the Group B standings.
Nigeria leapfrogged Tunisia to win the group by a single point and qualify for the World Cup for a fourth time.
Nigeria had been behind at half-time after a 15th-minute goal from Denis Oliech while Tunisia looked content to play a defensive game against their Mozambican hosts.
But the group was turned on its head in the second half of both matches, played simultaneously, as Nigeria fought back to go 2-1 ahead with Martins equalising on the hour mark and then Everton striker Yabuku Aiyegbeni scoring just three minutes later.
The match in Nairobi was stopped for several minutes after a barrage of bottles were thrown from an angry home crowd but when Allen Wetende brought back the score to 2-2 in the 79th minute, Kenyan jeers turned back to cheers.
Martins then grabbed the winner for Nigeria in the 83rd minute at around the same time as Mozambique finally broke down the Tunisian defence and atoned for several glaring misses throughout the game in Maputo with a goal from veteran striker Dario.
The 84th-minute winner from Dario ensured Mozambique finished third in the group and qualified for January's African Nations Cup finals in Angola.