Holders Egypt reach semi-finals
The 34-year-old midfielder, celebrating an African record 170th international appearance, equalised at the right end and later grabbed a controversial third goal for Egypt as they kept up their bid for an unprecedented third successive title.
After the game ended 1-1 in 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 next meet arch-rivals Algeria in Thursday's semi-final in Benguela.
"It was my fault for the first goal but the team showed great character in fighting back," Hassan told reporters.
"It is also what we did in our first game against Nigeria."
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 started badly when he flicked an inswinging corner from Achille Emana into his own net after 25 minutes.
Hassan, though, redeemed himself with a 35-metre free kick that dipped in front of Kameni and bounced into the net 12 minutes later.
The teams battled through a niggly second half and were restricted to a series of unsuccessful long-range efforts.
Cameroon's 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.
Cameroon captain Samuel Eto'o refused to blame defeat on Egypt's disputed third goal.
"We have to admit Egypt are a formidable team," he said.