The Atlas Lions of Morocco twice came from behind to draw Gabon 2-2 and finish top of Group C at the TotalEnergies Africa Cup of Nations, Cameroon 2021.
Allevinah and Boupendza twice gave the Panthers the lead before Boufal and Hakimi helped Morocco snatch a point and top spot.
The opening exchanges saw both sides cancelling each other in the middle of the park. The Panthers, who are missing the services of their talisman Aubameyang, look a threat on the break with Lloyd Palun and Bruno Ecuele Manga dominating the defence.
Guelor Kaku Kanga threaten the Atlas Lions goal when his fierce shot from distance narrowly missed the target.
Gabon found the breakthrough midway through the first half courtesy of Jim Ngowet Allevinah. Allevinah pounce on a defensive mistake in the Moroccan defence to slot past stand-in keeper Monir El Kajoui.
The Atlas Lions who had already cemented their place in the knockout stages after winning their opening two matches responded with a chance of their own. Jean Noel Amonome had to be alerted to deny El Kaabi an open goal from En-Nesyri's delivery.
Soufiane Chakla agonizingly headed wide of Amonome's goal before El Kaabi and Azz-Eddine Ounahi saw their efforts going off target.
The Moroccan goalkeeper pulled a brilliant double save to keep this side into the match on the stroke of half time. Monir El Kajoui tipped over Kanga's stinging free kick before stopping Lloyd Palun glancing header with a diving save.
Vahid Halilhodzic's side came close to drawing level inside the first minute of the second half through captain Faycal Fajr's long range effort.
Allevinah missed a chance to double the Panthers' advantage on 55 minutes. Boupendza found him with a neat through ball, latching on to it before firing wide. En-Nesyri had the ball into the Gabon goal on the hour mark but he was flagged offside.
Vahid Halilhodzic mixed things up introducing fresh legs as they chase the match. Substitute Boufal won and dispatched a penalty to draw level 20 minutes from time.
Gabon regained their lead ten minutes from time through a brilliant Boupendza strike. The forward latched on to Allevinah's pull back to beat Monir and give Gabon a 2-1 advance.
The Atlas Lions were not out of it as they draw level for the second time through Hakima's sumptuous free kick late to guarantee top spot in the group.
Morocco finish the group with 7 points two more than Gabon in second with while debutants Comoros move to third with 3 points and Ghana bottom with a point.
What they said after the game
Jim Allevinah (Man of the Match TotalEnergies):
"We showed a lot of solidarity and value. We are happy to achieve our goal. The draw is a good result for us against a good team from Morocco."
Patrice Neveu (Coach, Gabon):
"My team had the match they needed. The players followed the guidelines well. We thought we would win the match but this draw is still good, which allows us to continue the adventure. We would have liked to take the three points but it is football. In the round of 16 against Burkina Faso, it will be a difficult game against a team that plays well."
Vahid Halilhodzic (Coach, Morocco):
"We knew the match was going to be difficult. We were behind and my players were able to come back to score twice. We dominated but we lacked inspiration and success. I am satisfied with my players and their reaction. We have achieved our goal with first place in Group C."