The Carthage Eagles were defeated in their final group-stage game by Gambia, after a stoppage-time winner scored by Ablie Jallow.
The 1-0 reverse meant Tunisia finished third in Group F, and now face a difficult tie with tournament high-flyers Nigeria in the knockout stages.
Hannibal came on as a substitute in the 68th minute and received a yellow card, in what proved a turbulent second half for his country.
The 19-year-old saw his side miss a fantastic opportunity to take the lead in the first half, when Seifeddine Jaziri's penalty was saved by Gambia goalkeeper Boubacarr Gaye.