Achraf Hakimi's late stunner spared Morocco's blushes as it secured a 2-2 draw that takes them through to the following stage of the Africa Cup of Nations as Group C winners.
Coach Vahid Halilhodzic took the possibility to rest several key men, however that selection backfired inside the first half of, with Gabon well worth their twenty first-minute lead.
Jim Allevinah transformed past Munir Mohamedi after Nayef Aguerd slipped at the important second, and they might have made it to the wreck with a larger lead had been it not for the Morocco goalkeeper.
The Atlas Lions idea they'd equalised with an hour performed while a long ball from the again become missed through Gabon goalkeeper Jean Noel Amonome and went all of the way in, but Youssef En-Nesyri became deemed to were interfering with play in an offside role.
Morocco did get a slice of fortune 16 mins from time, alternative Sofiane Boufal triumphing a penalty despite Andre Biyogo Poko performing to win the ball, and the Angers attacker converted from 12 yards.
Gabon – with out Mario Lemina and Pierre-Emerick Aubameyang again – notion they'd snatched a win to pinnacle the institution as Aguerd placed into his very own net after 81 minutes, however Hakimi's free-kick three minutes later rescued Morocco.