Alexandria - Africa Cup of Nations debutants Madagascar kept their remarkable run going on Sunday with a penalty shootout victory over the Democratic Republic of Congo after a 2-2 draw to secure a place in the quarter-finals.
Ibrahim Amada's wonder strike put Madagascar ahead just nine minutes in at Alexandria Stadium but DR Congo responded swiftly as China-based forward Cedric Bakambu headed home his third goal in two matches.
Madagascar captain Faneva Andriatsima nodded the Indian Ocean islanders back ahead with a quarter-hour remaining only for Chancel Mbemba to haul DR Congo level at a corner in the final minute.
Marcel Tisserand and Yannick Bolasie both blazed over for DR Congo in the shootout as Madagascar prevailed 4-2 with their reward a meeting with four-time winners Ghana or 2004 champions Tunisia for a place in the semi-finals.
Marco Ilaimaharitra's suspension forced Madagascar coach Nicolas Dupuis to alter his line-up for the first time in the tournament with Rayan Raveloson deputising in midfield for a team that shocked Nigeria 2-0 to advance as group winners.
Britt Assombalonga replaced the injured Jonathan Bolingi in the lone change to the DR Congo side that trounced Zimbabwe 4-0, with captain Youssouf Mulumbu describing their qualification as a "miracle" following two opening losses.
Madagascan President Andry Rajoelina chartered a 480-seater plane to take fans to Egypt, and the travelling support were soon rejoicing when Amada blasted a sensational 25-yard strike that tailed away from Ley Matampi and flew in off the post.
The jubilant celebrations were halted midway through the first half though when Bakambu slipped free of the Madagascar centre-backs to glance in Glody Ngonda's bending cross.
Mbemba smashed over as another left-wing cross found the Malagasy defence in trouble, but this was a far more balanced contest than the last meeting - a 6-1 triumph for DR Congo in a 2017 Cup of Nations qualifier.
That hiding was the darkest day in Malagasy football history but they have undergone a dramatic transformation, and nearly regained the lead 10 minutes after the break when Jerome Mombris embarked on a driving run, his shot spilled by Matampi with Charles Andriamahitsinoro agonisingly hitting the rebound wide.
A battling Madagascar eventually regained the lead against a nation ranked 59 places above them when Andriatsima flung himself at a Romain Metanire cross following a superb long-busting run from the right-back.
Bolasie's tumble in the area provoked furious protests from DR Congo, with VAR not in use until the next round, but the Leopards conjured up another escape act in the 90th minute as an unmarked Mbemba headed in a corner to force extra time.
Madagascar goalkeeper Melvin Adrien kept his team level in extra time with a string of vital saves, the best an instinctive one-handed stop to repel another Mbemba header, while some desperate defending allowed the 'Barea' to take it to a shootout and add a further chapter to their Egyptian fairytale.