Former Continent's Best Player of the Year Victor Osimhen helped his team establish a 3-0 advantage, but the Super Eagles were compelled to hold on for a narrow win.
The three-time champions survived a dramatic comeback attempt from their opponents to advance to the last 16 of the Afcon tournament being held in Morocco.
The Super Eagles seemed to be in complete control in their Group C encounter in the Moroccan city, holding a three-goal cushion with just 17 minutes left courtesy of goals from Victor Osimhen, Wilfred Ndidi and Ademola Lookman.
Yet, a Tunisian defender pulled one back with a close-range finish from a Hannibal Mejbri free-kick, igniting hopes of a recovery.
The tension escalated when Tunisia were awarded a late penalty after a VAR check spotted a handball by Bright Osayi-Samuel. Ali Abdi converted in the 87th minute to set up a frantic conclusion.
The Carthage Eagles were inches away from a stunning leveler in stoppage time, with captain Ferjani Sassi directing a opportunity narrowly wide before a substitute sent a half-volley wide of the upright.
Securing First Place
This result means that Nigeria, winners of the competition on 3 previous occasions, advance to 6 points and are guaranteed first place in their pool with one game still to play.
In the next round, they will meet a best third-place team from one of Group A, B or F.
Meanwhile, the 2004 champions stay on 3 points, with Uganda and Tanzania locked on a single point each after playing out a one-all draw earlier on Saturday.
The final pool fixtures will see Nigeria stay in the city to take on Uganda on Tuesday, while the Eagles of Carthage return to the capital to confront Tanzania.
An Anxious Conclusion
The Tunisian defender smashed the ball from 12 yards to offer Tunisia a glimmer of hope of earning a draw.
The Super Eagles, finalists in the 2023 edition, become the next nation after Egypt to reach the next phase, but their manager and supporters will undoubtedly be breathing a sigh of relief.
What seemed set to be a comfortable last period transformed into a nerve-wracking conclusion.
The prolific striker had a goal ruled out for an infringement before opening the scoring right before half-time, expertly guiding a glancing effort into the far post from an Atalanta winger cross.
The lead was extended early in the second half when Wilfred Ndidi climbed above everyone to power home a header from a Lookman kick.
Osimhen then turned provider his teammate for the seemingly decisive goal, before the defender to steer a powerful header past the Nigerian shot-stopper to initiate the fightback.
The key incident came when a high ball struck the forearm of Bright Osayi-Samuel, with referee Boubou Traore awarding a penalty after consulting the VAR monitor.
Despite Ali Abdi's confident conversion, the 2004 champions in the end came up just short of pulling off a remarkable comeback.
Their fate is still in their own hands; a point against Tunisia will be sufficient to secure progression, and their coach will be keen to avoid a repeat of the 2013 group-stage exit that resulted in his departure.