Former African Footballer of the Year Victor Osimhen was instrumental in Nigeria build a commanding advantage, before the Super Eagles were compelled to hold on for a narrow victory.
Nigeria weathered a stunning late rally from Tunisia to progress to the knockout stage of the Afcon tournament taking place in Morocco.
Jose Peseiro's side appeared to be in complete control in their Group C clash in Fes, enjoying a 3-0 lead with just a quarter of an hour left thanks to goals from Victor Osimhen, Wilfred Ndidi and Ademola Lookman.
Yet, a Tunisian defender reduced the deficit with a powerful header from a Manchester United midfielder free-kick, sparking hopes of a recovery.
The drama escalated when the North Africans were given a late penalty after a video assistant referee check identified a handling offense by Bright Osayi-Samuel. Ali Abdi calmly slotted home in the dying stages to set up a frantic finale.
The Carthage Eagles came agonizingly close from a stunning leveler in added time, with captain Ferjani Sassi heading a chance just past the post before Ismael Gharbi sent a bobbling volley past the goal frame.
Clinching First Place
The victory means that the Super Eagles, champions of the tournament on three past instances, move to 6 group points and are guaranteed top spot in their pool with one game still to be contested.
For the round of 16, they will face a best third-place side from one of the other preliminary groups.
Meanwhile, the 2004 champions remain on 3 group points, with Uganda and Tanzania tied on a single point after playing out a 1-1 draw earlier on Saturday.
The final group matches will see Nigeria remain in Fes to take on the Cranes on Tuesday, while Tunisia return to the capital to confront Tanzania.
A Nervy Conclusion
The Tunisian defender drilled home from 12 yards to give his team hope of snatching a draw.
Nigeria, runners-up in the 2023 edition, are the next team after the Pharaohs to reach the next phase, but coach Eric Chelle and fans will undoubtedly be breathing a sigh of relief.
What seemed set to be a comfortable final quarter transformed into a nerve-wracking conclusion.
The prolific striker had a effort disallowed for an infringement before breaking the deadlock right before the interval, precisely placing a header into the bottom corner from an Ademola Lookman cross.
The lead was extended early in the second period when Wilfred Ndidi rose highest to thump in a powerful nod from a Lookman kick.
Osimhen then turned provider his teammate for the third goal, only for the defender to steer a header past goalkeeper Stanley Nwabali to initiate the fightback.
The key moment arrived when a looping cross struck the forearm of Bright Osayi-Samuel, with the official awarding a penalty after reviewing the pitchside screen.
Despite Ali Abdi's successful penalty, Tunisia ultimately came up just short of completing a remarkable recovery.
Tunisia's destiny remains in their control; a draw against Tanzania will be sufficient to secure progression, and their coach will be keen to prevent a repeat of the past group-stage exit that led to his departure.