Morocco drew 2-2 with Gabon in Yaounde in one of the best games of the Africa Cup of Nations so far as both sides progressed from Group C.
The Atlas Lions fell behind in the first half as Gabon’s Jim Allevinah slid past the onrushing keeper.
Morocco’s equaliser from the penalty spot by Sofiane Boufal after 74 minutes sparked a thrilling finale.
First, Gabon forced Nayef Aguerd into scoring an own goal before Achraf Hakimi curled home a free-kick.
Morocco will stay in the Cameroonian capital for their next game, against the best third-placed side from either Group A, B or F, on 25 January.
Gabon, meanwhile, will face Burkina Faso in Limbe as both sides kick off the Round of 16 on Sunday 23 January.
However, Ghana only won their qualifying group ahead of South Africa on goals scored and are unseeded for the play-off draw – where they will face one of Senegal, Morocco, Tunisia, Algeria and Nigeria for a place in Qatar.
Comoros, meanwhile, celebrated their three points heartily and now await the final round of matches in the remaining three groups to see if their stunning victory can extend their stay at the tournament.
Having exited in the group stage as hosts in 2017 and missed the 2019 finals altogether, Gabon were hugely impressive when reaching the knock-out stage for only the second time in the past 25 years.
They took the game to a Moroccan side who rested six players from the team that secured qualification for the knock-outs when beating Comoros 2-0 last time out.
Chance upon chance came their way with Aaron Boupendza, who was lively throughout, toe-poking wide just after the half-hour when it looked easier to hit the target.
Seven minutes before the break, Guelor Kanga hit a blistering free-kick from 40 yards that forced reserve keeper Monir El Kajoui to tip over the bar – just as he had to from the resulting corner when denying Lloyd Palun’s firm header with a fine stop.
Despite missing Pierre-Emerick Aubameyang, who had to take to social media to deny reports he had been out drinking prior to being sent back to England for checks on heart lesions seemingly developed after a Covid infection, Gabon continued to threaten.
Allevinah almost scored one of the goals of any Nations Cup when meeting a deep cross from a tight angle to fire against the bar with a strike that brought back memories of Marco van Basten’s stunning 1988 European Championship final goal.