Ex- Continent's Best Player of the Year Victor Osimhen was instrumental in his team build a 3-0 lead, before the Super Eagles were forced to defend resolutely for a hard-fought victory.
Nigeria weathered a dramatic comeback attempt from their opponents to progress to the knockout stage of the 2025 Africa Cup of Nations being held in the host nation.
The Super Eagles seemed to be in complete control in their Group C encounter in Fes, enjoying a three-goal lead with only a quarter of an hour remaining courtesy of strikes from Victor Osimhen, Wilfred Ndidi and Ademola Lookman.
However, a Tunisian defender reduced the deficit with a close-range finish from a Hannibal Mejbri set-piece, igniting hopes of a recovery.
The tension intensified when the North Africans were given a spot-kick after a VAR check identified a handball by Bright Osayi-Samuel. Ali Abdi calmly slotted home in the 87th minute to create a frantic conclusion.
Tunisia were inches away from a stunning leveler in added time, with captain Ferjani Sassi heading a opportunity just past the post before a substitute sent a bobbling volley wide of the upright.
The victory ensures that the Super Eagles, champions of the competition on 3 past instances, move to 6 group points and are guaranteed top spot in their pool with one game still to play.
In the next round, they will face a best third-place team from either Group A, B or F.
In the other match, Tunisia remain on 3 group points, with the East African teams locked on a single point each after registering a 1-1 draw in the day's other fixture.
The final group matches will see Nigeria stay in the city to play the Cranes on Tuesday, while Tunisia return to Rabat to confront the Taifa Stars.
The Tunisian defender drilled the ball from 12 yards to give Tunisia hope of snatching a draw.
Nigeria, runners-up in the previous tournament, become the next team after Egypt to reach the knockout stage, but coach Eric Chelle and fans will certainly be breathing a sigh of relief.
What seemed set to be a straightforward final quarter morphed into a nerve-wracking conclusion.
The prolific striker had a effort disallowed for an infringement before breaking the deadlock right before the interval, expertly guiding a glancing effort into the far post from an Ademola Lookman cross.
The lead was doubled soon in the second half when the Leicester City midfielder climbed above everyone to power home a header from a set-piece corner.
The number 9 then set up his teammate for the seemingly decisive goal, only for Montassar Talbi to steer a powerful header past goalkeeper Stanley Nwabali to begin the fightback.
The key incident came when a high ball hit the arm of the full-back, with the official pointing to the spot after consulting the VAR monitor.
Despite Ali Abdi's successful penalty, the 2004 champions in the end came up just short of pulling off a stirring comeback.
Tunisia's destiny remains in their own hands; a draw against Tunisia will be enough to see them through, and manager Sami Trabelsi will be eager to prevent a repeat of the past early elimination that resulted in his departure.
Lena is a tech journalist with over a decade of experience covering consumer electronics and emerging technologies.