Ex- African Footballer of the Year Victor Osimhen was instrumental in Nigeria establish a 3-0 lead, but they were forced to defend resolutely for a narrow win.
Nigeria survived a dramatic late rally from their opponents to advance to the last 16 of the 2025 Africa Cup of Nations taking place in Morocco.
The Super Eagles seemed to be in complete control in their pool encounter in Fes, enjoying a three-goal lead with just a quarter of an hour remaining courtesy of strikes from Victor Osimhen, Wilfred Ndidi and Ademola Lookman.
Yet, Montassar Talbi pulled one back with a powerful header from a Hannibal Mejbri set-piece, igniting hopes of a recovery.
The tension escalated when the North Africans were given a late penalty after a VAR check identified a handling offense by Bright Osayi-Samuel. Ali Abdi converted in the 87th minute to set up a nail-biting conclusion.
The Carthage Eagles were inches away from a stunning leveler in added time, with their skipper heading a opportunity narrowly wide before a substitute sent a half-volley past the upright.
Clinching First Place
The victory means that Nigeria, winners of the tournament on 3 previous occasions, move to 6 points and are assured first place in Group C with a match left to play.
For the round of 16, they will meet a third-placed side from either Group A, B or F.
In the other match, the 2004 champions remain on three points, with the East African teams locked on one point each after playing out a 1-1 stalemate in the day's other fixture.
The concluding pool fixtures will see the group leaders stay in Fes to play Uganda on Tuesday, while the Eagles of Carthage return to the capital to confront Tanzania.
A Nervy Conclusion
The Tunisian defender drilled home from the penalty spot to offer his team a glimmer of hope of snatching a draw.
The Super Eagles, finalists in the previous edition, become the second nation after Egypt to reach the knockout stage, but coach Eric Chelle and fans will certainly be breathing a sigh of relief.
What looked like set to be a comfortable final quarter transformed into a tense conclusion.
The prolific striker had a effort disallowed for offside before opening the scoring right before half-time, expertly guiding a header into the bottom corner from an Atalanta winger delivery.
The advantage was doubled early in the second half when Wilfred Ndidi climbed above everyone to power home a powerful nod from a set-piece kick.
The number 9 then set up his teammate for the third goal, only for Montassar Talbi to steer a powerful header past goalkeeper Stanley Nwabali to begin the fightback.
The key incident came when a looping cross hit the arm of the full-back, with referee Boubou Traore awarding a penalty after consulting the VAR monitor.
Despite the defender's successful penalty, Tunisia ultimately fell short of completing a remarkable recovery.
Their fate remains in their control; a draw against Tunisia will be enough to see them through, and their coach will be eager to prevent a repeat of the 2013 group-stage exit that led to his previous resignation.