Former Continent's Best Player of the Year Victor Osimhen was instrumental in his team build a 3-0 lead, but they were compelled to hold on for a narrow win.
Nigeria survived a stunning comeback attempt from their opponents to advance to the knockout stage of the Afcon tournament being held in Morocco.
Jose Peseiro's side seemed to be in complete control in their pool clash in the Moroccan city, holding a three-goal lead with just a quarter of an hour remaining courtesy of goals from their attacking trio.
Yet, Montassar Talbi pulled one back with a close-range finish from a Manchester United midfielder free-kick, sparking hopes of a turnaround.
The tension escalated when the North Africans were given a spot-kick after a video assistant referee review spotted a handling offense by Bright Osayi-Samuel. Ali Abdi converted in the dying stages to set up a nail-biting finale.
The Carthage Eagles were inches away from a stunning leveler in added time, with captain Ferjani Sassi heading a opportunity just past the post before Ismael Gharbi sent a half-volley past the goal frame.
Securing Top Spot
The victory ensures that Nigeria, winners of the competition on three previous occasions, move to 6 points and are assured first place in their pool with a match left to be contested.
In the next round, they will face a third-placed team from one of the other preliminary groups.
In the other match, the 2004 champions remain on 3 points, with Uganda and Tanzania tied on a single point each after playing out a one-all draw in the day's other fixture.
The final group fixtures will see Nigeria remain in Fes to play Uganda on the next matchday, while the Eagles of Carthage return to the capital to face the Taifa Stars.
An Anxious Finish
The Tunisian defender drilled the ball from 12 yards to give his team a glimmer of hope of snatching a point.
Nigeria, finalists in the previous tournament, become the second nation after the Pharaohs to reach the next phase, but their manager and supporters will certainly be breathing a sigh of relief.
What seemed set to be a comfortable final quarter transformed into a tense conclusion.
The prolific striker had a goal ruled out for an infringement before opening the scoring right before the interval, precisely placing a glancing effort into the bottom corner from an Ademola Lookman cross.
The advantage was doubled early in the second half when Wilfred Ndidi rose highest to power home a powerful nod from a Lookman corner.
Osimhen then turned provider his teammate for the third goal, only for the defender to steer a powerful header past the Nigerian shot-stopper to begin the fightback.
The pivotal incident arrived when a looping cross struck the arm of the full-back, with referee Boubou Traore awarding a penalty after reviewing the pitchside screen.
Although Ali Abdi's confident conversion, Tunisia ultimately fell short of pulling off a remarkable recovery.
Their fate is still in their control; a draw against Tanzania will be enough to see them through, and their coach will be keen to avoid a repeat of the past early elimination that led to his previous resignation.