Egypt captain Ahmed Hassan scored three times, including an own goal, as the two-time Africa Cup holders beat Cameroon 3-1 in extra-time to advance into the semi-finals.
The 34-year-old midfielder, celebrating an African record 170th international appearance, grabbed the equaliser and a controversial third for Egypt as they kept up their bid for an unprecedented third successive title.
"I'm very happy because we won today," Hassan said. "We played a very good match, and I'm thrilled to score two goals and also with the record of 170 appearances."
After the game ended 1-1 over 90 minutes, Mohamed Nagui and Hassan netted in extra time to extend Egypt's record unbeaten run at the Nations Cup to 17 games.
The champions are now set to meet north African arch-rivals Algeria in Thursday's semi-final in Benguela.
Nigeria will play West African rivals Ghana in Luanda after winning 5-4 on penalties after a 0-0 draw with Zambia.
Extra time resurgence
Hassan's 94th-minute free kick, which was partially blocked by Cameroon goalkeeper Idriss Carlos Kameni and bounced back off the woodwork, was adjudged to have crossed the line, even though television replays indicated otherwise.
The goal came three minutes after substitute Nagui had put Egypt 2-1 up in an error-strewn match at the Ombaka Stadium.
Nagui pounced to score after a wayward back pass by experienced full-back Geremi.
Hassan's landmark game had started badly when he flicked an in-swinging corner from Achille Emana into his own net after 25 minutes.
Hassan, though, redeemed himself 12 minutes later with a 35-metre strike that dipped just in front of Kameni and bounced into the net.
The teams battled through a niggly second half, which Cameroon dominated, and managed only a series of unsuccessful long-range efforts.
Cameroon's late hopes took a knock when defender Aurelien Chedjou was sent off for a professional foul with nine minutes left in extra-time.
Chedjou was preferred in the starting line-up to Rigobert Song, whose run of 36 successive Nations Cup finals matches stretching back to 1996 came to an end.
'For all Egyptians'
"This is a very important win for the Egyptian team and for all the Egyptians," Hassan said.
"We are very happy but we must now prepare ourselves well for Algeria."
In the late quarter-final in Lubango, Thomas Nyirenda was the only player to miss as Zambia went down 5-4 to Nigeria on penalties after a 0-0 draw.
Both goalkeepers scored their spot kicks, with Nigeria's Vincent Enyeama hitting the winner.
Nigeria had been reduced to ten men in extra-time as Onyekachi Apam was sent off for a second bookable offence.