Ferjani Sassi’s heavily deflected strike gave Tunisia the lead early in the second half at Al Salam Stadium and Youssef Msakni squeezed home a second on 60 minutes.
Naim Sliti added a third in injury time to send Tunisia through to a semi-final showdown with Sadio Mane’s Senegal, with the Carthage Eagles into the last four for the first time since clinching their only title when they hosted the 2004 edition.
Tunisia boss Alain Giresse recalled Wahbi Khazri in attack as the lone change to the side that overcame Ghana in a last-16 penalty shootout, while Marco Ilaimaharitra returned from suspension as Madagascar fielded the same team used throughout the group phase.
Tunisia, the continent’s second-ranked side at 25th in the world, had reached the quarter-finals here without winning a single game following four successive draws.
After matches in Suez and Ismailia, this was a first Cairo outing for the Carthage Eagles, who controlled possession early but didn’t truly threaten until a sweetly struck Khazri free-kick was superbly flicked onto the bar by Madagascar goalkeeper Melvin Adrien.
Ghailene Chaalali forced Adrien to push an awkward low shot behind while Mouez Hassen, apologetic after his angry reaction to being substituted ahead of the shootout in the last round, was largely untested bar from a long-range Ibrahim Amada effort.
Madagascar were trying to become the first newcomers since South Africa in 1996 to reach the semi-finals, but their hopes were effectively extinguished by the hour.
Khazri saw a goal disallowed for offside straight after half-time, but Sassi struck minutes later when his tame shot from the edge of the area hit Thomas Fontaine and spun past a helpless Adrien.
Msakni then promptly doubled Tunisia’s advantage, jumping on a rebound to slip the ball low beyond Adrien moments after he parried a shot from Khazri.
Charles Andriamahitsinoro, who scored twice for Madagascar in the group stage, looked to be through on goal after a long punt forward but failed to muster a shot. Amada was unable to reproduce his wonder strike from the DR Congo tie as he sliced wide from distance.
This was the first competitive meeting between the countries in almost two decades, and while Nicolas Dupuis has transformed Madagascar from a team once ranked 190th, Sliti’s injury-time goal ensured it was the end of a remarkable adventure for the ‘Barea’.
For more news your way, download The Citizen’s app for iOS and Android.
Download our app and read this and other great stories on the move. Available for Android and iOS.