LIBREVILLE, Gabon — The fallen giant of the African Cup of Nations is rising again as Egypt became the final team on Sunday to force its way into the semifinals amid late drama.

The record seven-time champion, held back by years of political upheaval back home, returned to the last four for the first time since 2010 with an 87th-minute winner over Morocco in the last quarterfinal in Gabon.

Mahmoud Kahraba hooked in a volley in a goalmouth scramble at the end, giving the Egyptians a 1-0 win and their 44-year-old goalkeeper a chance to taste success one more time.

Celebrations at the final whistle centred on goalkeeper Essam el-Hadary, who has won four African titles with Egypt, the first an astonishing 19 years ago. El-Hadary hugged his defenders after watching Morocco's last chance sail wide of his goal at the Stade de Port-Gentil on Gabon's Atlantic coast.

He wasn't meant to be there, but has ended up captaining the team after the other two 'keepers in the squad picked up injuries.

With el-Hadary and his defence holding out under second-half pressure from Morocco, Egypt joined Ghana as quarterfinal winners on Sunday, with Ghana's 2-1 win over Congo in the day's first game sealed by goals from the Ayew brothers, Jordan and Andre.

Burkina Faso and Cameroon progressed to the semifinals on Saturday, and all four quarterfinal games kept fans on edge until the end.

Burkina Faso beat Tunisia with two goals in the last nine minutes, Cameroon knocked out Senegal in a penalty shootout, Ghana killed off Congo's challenge with a late penalty, and substitute Kahraba gave Egypt its last-gasp win over North African rival Morocco.

Gone in Gabon are title favourite Senegal and also Morocco and coach Herve Renard, who was seeking a third triumph with a third different team.

Still alive in a throwback African Cup are the three most successful teams in the history of the tournament.

Egypt qualified this year for the first time since winning a third straight title and seventh overall in 2010. Cameroon and Ghana are both four-time champions, but Cameroon last won 15 years ago and Ghana's long wait to be champion of Africa again — it's now 35 years and counting — is becoming African Cup folklore.

And then there's the outsider, Burkina Faso, which reached the final in 2013 but certainly wasn't expected to be in the semifinals in Gabon. In the semifinals, it's Egypt vs. Burkina Faso on Wednesday and Ghana vs. Cameroon on Thursday.

In Port-Gentil, el-Hadary and Egypt maintained their record of not conceding a goal at this tournament as Morocco was frustrated for much of the second half. M'Bark Boussoufa hit the crossbar with a long curling shot in the 55th minute that, for once, had el-Hadary beaten. Forward Aziz Bouhaddouz missed three good chances for Morocco after that.

It opened the way for Kahraba. He partially connected with a header from a late corner, the ball bounced back toward him off a Moroccan defender and, with players scrambling to get to it, Kahraba stuck out his leg to hook the ball into the net.

Earlier, Jordan Ayew gave Ghana the lead and older brother Andre Ayew swept in a 78th-minute penalty for the winner to beat Congo at Stade d'Oyem.

At 1-1, the definitive moment came when Christian Atsu sped onto a pass late on and was tripped by Lomalisa Mutambala, giving Andre Ayew his chance from the spot.

He took it, and Ghana progressed to the semifinals for the sixth straight time. That hasn't meant much for Ghana, though. It's still looking for a first triumph since 1982.

Ghana has lost in three finals and four semifinals since '82, including an agonizing defeat in a penalty shootout to Ivory Coast in the deciding game at the last African Cup. That experience two years ago left Andre Ayew sobbing and inconsolable.

The painful memories will likely keep Ghanaian feet on the ground this year, even after getting past Congo, a tricky adversary. Congo's equalizer was a fabulous curving shot from long range by Paul-Jose Mpoku. It led Congo goalkeeper Ley Matampi to revive the sitting-down, bottom-shuffle celebration made famous by former 'keeper Robert Kidiaba when Congo made the semifinals two years ago.

Ghana pulled itself together and Andre Ayew put Matampi on his backside again after sending him the wrong way for the match-winning spot-kick.

Like el-Hadary and Egypt, these Ghanaians have strong ties to African Cup history: The Ayew brothers are the sons of Abedi Pele, a member of the last Ghana team to lift the African Cup more than three decades ago.

___

Follow Gerald Imray on Twitter at https://twitter.com/GeraldImrayAP