Former Continent's Best Player of the Year the Napoli star was instrumental in Nigeria build a commanding advantage, before they were forced to hold on for a hard-fought victory.
The three-time champions survived a stunning late rally 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 clash in Fes, holding a three-goal lead with only 17 minutes remaining courtesy of strikes from Victor Osimhen, Wilfred Ndidi and Ademola Lookman.
However, Montassar Talbi pulled one back with a powerful header from a Manchester United midfielder free-kick, sparking hopes of a recovery.
The tension escalated when Tunisia were awarded a late penalty after a video assistant referee check identified a handball by the Nigerian defender. Ali Abdi converted in the 87th minute to set up a frantic conclusion.
Tunisia came agonizingly close from a stunning equalizer in added time, with their skipper heading a chance narrowly wide before a substitute guided a half-volley wide of the upright.
The victory means that Nigeria, winners of the competition on 3 past instances, move to 6 points and are assured first place in Group C with one game left to be contested.
For the round of 16, they will meet a third-placed team from either Group A, B or F.
In the other match, Tunisia stay on three group points, with the East African teams locked on a single point after registering a one-all draw in the day's other fixture.
The final group matches will see the group leaders remain in the city to take on the Cranes on the next matchday, while the Eagles of Carthage return to the capital to confront the Taifa Stars.
Ali Abdi smashed the ball from the penalty spot to give Tunisia hope of earning a point.
Nigeria, runners-up in the 2023 edition, become the second nation after the Pharaohs to reach the knockout stage, but coach Eric Chelle and fans will certainly be feeling relieved.
What looked like set to be a straightforward final quarter morphed into a nerve-wracking affair.
Victor Osimhen had a effort ruled out for offside before opening the scoring on the stroke of half-time, precisely placing a header into the far post from an Ademola Lookman cross.
The advantage was extended soon in the second period when the Leicester City midfielder rose highest to power home a header from a Lookman corner.
Osimhen then set up Lookman for the third goal, only for the defender to steer a powerful header past goalkeeper Stanley Nwabali to initiate the comeback.
The key moment came when a looping cross hit the forearm of the full-back, with referee Boubou Traore awarding a penalty after consulting the pitchside screen.
Despite the defender's successful penalty, Tunisia in the end came up just short of completing a stirring comeback.
Tunisia's destiny is still in their own hands; a draw against Tanzania will be sufficient to secure progression, and their coach will be eager to prevent a recurrence of the 2013 early elimination that led to his previous resignation.
Cybersecurity expert with over a decade in data protection, specializing in secure cloud architectures and privacy compliance.