Former African Footballer of the Year the Napoli star was instrumental in Nigeria build a commanding advantage, but they were compelled to defend resolutely for a narrow win.
The three-time champions survived a dramatic late rally from their opponents to advance to the knockout stage of the Afcon tournament taking place in the host nation.
Jose Peseiro's side seemed to be in complete control in their Group C encounter in the Moroccan city, holding a 3-0 cushion with just 17 minutes remaining courtesy of goals from Victor Osimhen, Wilfred Ndidi and Ademola Lookman.
However, Montassar Talbi pulled one back with a powerful header from a Manchester United midfielder set-piece, sparking hopes of a recovery.
The drama escalated when Tunisia were awarded a spot-kick after a VAR review identified 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 stunning equalizer in stoppage time, with their skipper heading a opportunity just past the post before a substitute guided a bobbling volley past the upright.
The victory means that the Super Eagles, champions of the tournament on 3 previous occasions, advance to 6 group points and are assured first place in Group C with a match left to be contested.
For the round of 16, they will meet a best third-place side from either the other preliminary groups.
Meanwhile, the 2004 champions remain on three points, with Uganda and Tanzania tied on one point after registering a one-all draw earlier on Saturday.
The final group matches will see the group leaders remain in the city to play Uganda on Tuesday, while the Eagles of Carthage travel back to the capital to face Tanzania.
Ali Abdi drilled home from 12 yards to give Tunisia a glimmer of hope of earning a point.
The Super Eagles, finalists in the previous edition, are the second team after the Pharaohs to reach the knockout stage, but coach Eric Chelle and fans will certainly be feeling relieved.
What seemed set to be a straightforward final quarter morphed into a nerve-wracking affair.
Victor Osimhen had a goal ruled out for an infringement before breaking the deadlock on the stroke of half-time, expertly guiding a glancing effort into the bottom corner from an Atalanta winger cross.
The advantage was doubled soon in the second period when the Leicester City midfielder rose highest to power home a powerful nod from a Lookman corner.
The number 9 then set up his teammate for the seemingly decisive goal, before Montassar Talbi to direct a powerful header past goalkeeper Stanley Nwabali to begin the fightback.
The pivotal incident came when a high ball struck the forearm of the full-back, with the official awarding a penalty after consulting the pitchside screen.
Although Ali Abdi's confident conversion, the 2004 champions in the end came up just short of pulling off a remarkable comeback.
Tunisia's destiny is still in their own hands; a draw against Tunisia will be sufficient to secure progression, and manager Sami Trabelsi will be keen to avoid a repeat of the past early elimination that led to his departure.
A financial analyst with over a decade of experience in trading and market research, specializing in technical analysis and risk management.