Ex- Continent's Best Player of the Year Victor Osimhen was instrumental in Nigeria establish a commanding lead, but they were compelled to defend resolutely for a hard-fought victory.
The three-time champions survived a stunning late rally from Tunisia to progress to the knockout stage of the 2025 Africa Cup of Nations being held in Morocco.
Jose Peseiro's side appeared to be cruising in their Group C clash in Fes, enjoying a 3-0 cushion with only 17 minutes remaining thanks to goals from their attacking trio.
Yet, Montassar Talbi pulled one back with a powerful header from a Hannibal Mejbri set-piece, sparking hopes of a recovery.
The drama escalated when the North Africans were given a late penalty after a VAR check spotted a handling offense by Bright Osayi-Samuel. Ali Abdi calmly slotted home in the 87th minute to create a nail-biting conclusion.
Tunisia came agonizingly close from a stunning equalizer in added time, with captain Ferjani Sassi heading a opportunity just past the post before Ismael Gharbi guided a half-volley wide of the upright.
The victory means that the Super Eagles, champions of the tournament on 3 past instances, move to six group points and are assured top spot in their pool with a match still to be contested.
In the next round, they will meet a third-placed team from either the other preliminary groups.
In the other match, Tunisia stay on three group points, with Uganda and Tanzania locked on a single point each after registering a one-all draw in the day's other fixture.
The final group fixtures will see Nigeria stay in Fes to take on the Cranes on Tuesday, while Tunisia travel back to Rabat to confront the Taifa Stars.
The Tunisian defender smashed home from the penalty spot to offer his team hope of snatching a draw.
Nigeria, finalists in the 2023 tournament, become the next team after Egypt to reach the knockout stage, but their manager and fans will undoubtedly be breathing a sigh of relief.
What looked like set to be a comfortable final quarter morphed into a tense conclusion.
Victor Osimhen had a effort disallowed for an infringement before breaking the deadlock on the stroke of the interval, precisely placing a header into the bottom corner from an Atalanta winger cross.
The lead was doubled early in the second half when the Leicester City midfielder climbed above everyone to power home a powerful nod from a Lookman corner.
Osimhen then set up his teammate for the third goal, only for Montassar Talbi to direct a powerful header past the Nigerian shot-stopper to begin the fightback.
The key moment arrived when a high ball struck the arm of the full-back, with the official pointing to the spot after reviewing the VAR monitor.
Despite Ali Abdi's successful penalty, the 2004 champions in the end fell short of pulling off a stirring recovery.
Their fate is still in their own hands; a draw against Tanzania will be sufficient to secure progression, and their coach will be keen to prevent a recurrence of the past group-stage exit that resulted in his departure.