Former African Footballer of the Year Victor Osimhen was instrumental in his team build a commanding lead, but they were forced to defend resolutely for a hard-fought win.
Nigeria survived a dramatic comeback attempt from their opponents to advance to the last 16 of the Afcon tournament being held in Morocco.
The Super Eagles appeared to be in complete control in their pool encounter in Fes, enjoying a 3-0 lead with only a quarter of an hour remaining thanks to goals from Victor Osimhen, Wilfred Ndidi and Ademola Lookman.
However, a Tunisian defender pulled one back with a powerful header from a Manchester United midfielder free-kick, sparking hopes of a recovery.
The tension intensified when the North Africans were awarded a late penalty after a video assistant referee check spotted a handball by the Nigerian defender. The left-back calmly slotted home in the dying stages to create a nail-biting finale.
Tunisia came agonizingly close from a stunning equalizer in added time, with their skipper directing a opportunity just past the post before Ismael Gharbi sent a bobbling volley past the upright.
Clinching First Place
The victory means that Nigeria, champions of the tournament on 3 previous occasions, move to 6 points and are guaranteed top spot in Group C with a match still to play.
For the round of 16, they will face a best third-place side from one of Group A, B or F.
Meanwhile, Tunisia stay on 3 points, with the East African teams locked on one point after playing out a 1-1 draw in the day's other fixture.
The concluding group matches will see Nigeria remain in Fes to take on Uganda on Tuesday, while Tunisia return to the capital to face the Taifa Stars.
An Anxious Conclusion
Ali Abdi smashed the ball from 12 yards to give Tunisia hope of earning a point.
The Super Eagles, runners-up in the previous tournament, become the next nation after Egypt to reach the knockout stage, but coach Eric Chelle and supporters will certainly be feeling relieved.
What looked like set to be a straightforward final quarter morphed into a tense conclusion.
Victor Osimhen had a effort disallowed for offside before breaking the deadlock right before the interval, precisely placing a header into the far post from an Atalanta winger cross.
The advantage was extended soon in the second half when Wilfred Ndidi rose highest to thump in a powerful nod from a Lookman kick.
The number 9 then set up Lookman for the third goal, before Montassar Talbi to direct a powerful header past goalkeeper Stanley Nwabali to initiate the comeback.
The pivotal moment arrived when a high ball struck the forearm of the full-back, with referee Boubou Traore awarding a penalty after consulting the VAR monitor.
Although Ali Abdi's confident conversion, the 2004 champions in the end came up just short of pulling off a stirring comeback.
Their fate remains in their own hands; a point against Tunisia will be enough to secure progression, and manager Sami Trabelsi will be eager to avoid a recurrence of the 2013 early elimination that led to his departure.