Former African Footballer of the Year Victor Osimhen helped his team establish a commanding lead, but the Super Eagles were forced to hold on for a narrow victory.
Nigeria survived a dramatic comeback attempt from Tunisia to advance to the last 16 of the Afcon tournament taking place in the host nation.
Jose Peseiro's side seemed to be cruising in their pool clash in Fes, enjoying a three-goal cushion with only 17 minutes left courtesy of strikes from Victor Osimhen, Wilfred Ndidi and Ademola Lookman.
Yet, Montassar Talbi pulled one back with a close-range finish from a Manchester United midfielder free-kick, sparking hopes of a turnaround.
The drama escalated when Tunisia were awarded a late penalty after a VAR review spotted a handball by the Nigerian defender. The left-back calmly slotted home in the dying stages to set up a frantic conclusion.
Tunisia came agonizingly close from a last-gasp leveler in stoppage time, with captain Ferjani Sassi heading a opportunity narrowly wide before Ismael Gharbi guided a half-volley past the upright.
The victory means that the Super Eagles, champions of the tournament on 3 past instances, move to 6 group 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 team from either Group A, B or F.
In the other match, Tunisia remain on three points, with Uganda and Tanzania locked on one point each after playing out a 1-1 stalemate in the day's other fixture.
The final group fixtures will see the group leaders stay in Fes to play Uganda on Tuesday, while Tunisia travel back to Rabat to face the Taifa Stars.
Ali Abdi drilled home from the penalty spot to offer Tunisia hope of snatching a draw.
Nigeria, finalists in the 2023 tournament, are the second team after Egypt to reach the knockout stage, but coach Eric Chelle and supporters will undoubtedly be feeling relieved.
What seemed set to be a comfortable final quarter morphed into a nerve-wracking conclusion.
Victor Osimhen had a effort ruled out for an infringement before opening the scoring right before half-time, expertly guiding a header into the bottom corner from an Ademola Lookman cross.
The advantage was doubled early in the second half when the Leicester City midfielder climbed above everyone to thump in a powerful nod from a Lookman kick.
The number 9 then turned provider his teammate for the third goal, before the defender to steer a powerful header past the Nigerian shot-stopper to initiate the fightback.
The key moment came when a high ball hit the forearm of Bright Osayi-Samuel, with referee Boubou Traore awarding a penalty after reviewing the VAR monitor.
Although the defender's confident conversion, the 2004 champions ultimately came up just short of completing a remarkable recovery.
Their fate remains in their own hands; a draw against Tanzania will be sufficient to secure progression, and manager Sami Trabelsi will be keen to avoid a repeat of the past early elimination that resulted in his previous resignation.
Elara is a seasoned betting analyst with a passion for helping others make informed wagers and enjoy responsible gaming.