The draw saw the Atlas Lions, who came into the match having already qualified for the knockout phase, finish at the top of the group standings and they were joined in the Last 16 by the Panthers who finished second on the table.
The Atlas Lions dominated the match from the first whistle, but the 1976 African champions found it difficult to penetrate the Panthers’ defence which was marshalled by the experienced Bruno Ecuele Manga.
It was Gabon who broke the deadlock in the 21st minute against the run of play.
Jim Allevinah ran onto a through ball and scored to make it 1-0 to the Panthers with Sofian Chakla having slipped up at the back.
The goal fired up the Panthers and they went in search of their second goal of the match.
Goalkeeper Munir El Kajoui produced a fantastic finger tipping save to deny Lloyd Palun, whose headed effort was goal bound.
Gabon then contained the much-fancied Moroccans and they were leading 1-0 during the half-time break.
An entertaining second-half followed as Gabon and Morocco were both determined to score goals with Allevinah coming very close to grabbing his brace when his volleyed effort hit the top of the crossbar with Munir well beaten.
Vahid Halilhodzic, the Morocco coach, introduced Sofiane Boufal, who injected some pace into the Atlas Lions’ box attack and they were awarded a penalty after the speedy player was fouled in the box.
Boufal then converted the resulted penalty to make it 1-1.
The 74th-minute goal ensured that the game was evenly poised in the closing stages as the two teams pushed for a late winning goal.
Nayef Aguerd netted an own-goal from Allevinah’s cross to make it 2-1 to Gabon with nine minutes left.
However, the Atlas Lions fought back and they level matters through Achraf Hakimi’s superb free-kick in the 84th minute and ultimately, the entertaining encounter ended in a 2-2 draw on the night.
Gabon (1) 2 (Allevinah 21′, Aguerd 81′)
Morocco (0) 2 (Boufal 74′, Hakimi 84′)
Gabon: Amonome, Moucketou-Moussounda (Autchanga 64′), Assoumou, Ecuele Manga, Palun, Oyono, Obiang, Biyogo Poko, Kanga, Boupendza (Meye 90’+1), Allevinah (Mayi 88′).
Morocco: Munir, Hakimi, Chakla (Saiss 89′), Aguerd, Masina, Amrabat, Ounahi (Tissoudali 89′), Chair (Amallah 31′), Fajr (Barkok 57′), En-Nesyri, El Kaabi (Boufal 57′).
AFCON: Morocco tops Group C after 2-2 draw against Gabon