(CNN) -- Two goals in five minutes at the start of extra-time helped defending champions Egypt book their place in the African Nations Cup semifinals with a battling 3-1 victory over Cameroon.
The game, though, was marred by a controversial third goal by midfielder Ahmed Hassan which was allowed to stand by referee Jerome Damon despite replays showing the ball had clearly not crossed the line.
By that time the Pharaohs' captain, who was winning a record 170th cap for his country, had already scored an own goal to put the Indomitable Lions ahead after 26 minutes.
Hassan scored again at the other end to pull his side level with a powerful long-range strike before half-time which eventually forced the game into an additional 30 minutes in Benguela.
Substitute Mohamed Gedo then capitalized on an error from Geremi Njitap to put Egypt ahead in extra-time, before Hassan's controversial strike handed them a two-goal cushion.
To make matters worse for Paul Le Guen's Cameroon, Aurelien Chedjou was sent off late on as the north Africans set up a tantalising last-four clash with old foes Algeria.
Cameroon took the lead following a spell of intense pressure. A succession of Achille Emana corners had the Egyptian defence wobbling -- and the seventh one resulted in Hassan's weak-header on the line dropping into his own net.
Cameroon pressed for a second goal but were taken by surprise when Hassan unleashed a fierce 35-yard strike in the 37th minute that deceived goalkeeper Carlos Kameni before finding its way in.
Emad Moteab could have won the game for Egypt right at the death after he was picked out at the back post by a sweeping pass from Hassan, but the Al-Ahly forward could only find the side netting as the game entered extra-time.
However, Hassan Shehata's side wasted no time in killing off the tie going 3-1 up after 95 minutes -- after being gifted both goals.
The first came when Geremi's poor back-pass from the right was intercepted by Gedo, who and tucked away with ease through the legs of Kameni two minutes after the resumption.
The second seems certain to land South African referee Damon in the spotlight after Hassan's free-kick from the left was pushed onto the underside of the crossbar by the Espanyol goalkeeper and did not cross the line when it hit the ground.
However, it was still allowed to stand much to the dismay of the Cameroon players. It also seemed to knock the stuffing out of Le Guen's men as they failed to create any major openings in the closing 25 minutes.
To add insult to injury, Chedjou was shown a straight red for hauling down last-man Gedo midway through the second period of extra-time with Egypt going on to seal a memorable win.
Meanwhile, Nigeria became the fourth team to reach the semifinals after defeating Zambia in a dull final quarterfinal showdown in Lubango.
Neither side could find the net after 90 minutes and 30 minutes of extra time, but Nigeria progressed 5-4 on penalties and will now face near-neighbors Ghana in the last four on Thursday.
Goalkeeper Vincent Enyeama scored the decisive penalty for Nigeria after Thomas Nyirenda had missed for Zambia.
Enyeama dived to his right to stop Nyirenda's penalty after Sikombe Chivhuta and Christopher Katongo and Emmanuel Mayuka had all scored for Zambia.
Obefemi Martins, Victor Nsofor, Peter Odemwingie, and John Obi Mikel all scored for Nigeria.