Ex- African Footballer of the Year Victor Osimhen was instrumental in his team build a commanding advantage, before the Super Eagles were compelled to defend resolutely for a hard-fought victory.
Nigeria survived a stunning late rally from Tunisia to advance to the knockout stage of the 2025 Africa Cup of Nations being held in Morocco.
Jose Peseiro's side appeared to be in complete control in their Group C clash in Fes, holding a three-goal lead with only 17 minutes left thanks to goals from their attacking trio.
However, a Tunisian defender reduced the deficit with a close-range finish from a Hannibal Mejbri free-kick, igniting hopes of a turnaround.
The drama escalated when the North Africans were given a late penalty after a video assistant referee check spotted a handling offense by the Nigerian defender. The left-back converted in the dying stages to set up a nail-biting conclusion.
Tunisia came agonizingly close from a stunning leveler in stoppage time, with captain Ferjani Sassi heading a chance narrowly wide before Ismael Gharbi guided a half-volley wide of the goal frame.
This result means that Nigeria, champions of the competition on 3 previous occasions, advance to six group points and are assured first place in Group C with one game left to play.
For the round of 16, they will face a best third-place side from either Group A, B or F.
In the other match, Tunisia stay on three points, with the East African teams locked on one point after playing out a one-all draw earlier on Saturday.
The concluding group fixtures will see Nigeria remain in Fes to play Uganda on the next matchday, while Tunisia travel back to Rabat to confront the Taifa Stars.
The Tunisian defender smashed the ball from 12 yards to offer Tunisia hope of snatching a point.
Nigeria, runners-up in the 2023 tournament, become the second nation 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 transformed into a nerve-wracking affair.
Victor Osimhen had a effort ruled out for offside before breaking the deadlock right before half-time, precisely placing a glancing effort into the bottom corner from an Ademola Lookman delivery.
The advantage was doubled soon in the second period when Wilfred Ndidi rose highest to power home a header from a Lookman corner.
The number 9 then turned provider his teammate for the seemingly decisive goal, only for the defender to direct a powerful header past goalkeeper Stanley Nwabali to begin the fightback.
The key incident arrived when a looping cross struck the arm of Bright Osayi-Samuel, with the official awarding a penalty after reviewing the VAR monitor.
Although Ali Abdi's successful penalty, the 2004 champions in the end came up just short of completing a stirring comeback.
Their fate remains in their own hands; a point against Tanzania will be enough to see them through, and their coach will be eager to avoid a recurrence of the 2013 group-stage exit that led to his previous resignation.