Title holders Morocco reached the quarterfinals of the TOTAL African Nations Championship (CHAN) when beating Uganda 5-2 in Douala on Tuesday.
A second-half revival by the Atlas Lions secured their emphatic victory at the Stade de la Réunification to ensure they finish top of Group C.
The result means the Cranes crash out of the competition as they finish top of the group with just one point after three matches in the group.
Two goals by Soufiane Rahimi and further strikes by Ayoub El Kaabi, Hamza El Moussaoui, and an own goal by goalkeeper Charles Lukwago steered the Atlas Lions to the victory.
Midfielders Ibrahim Orit and Saidi Kyeyune scored for the Ugandans but their efforts were not enough to prevent them from the heavy defeat.
Morocco top the group with seven points and keep their hopes of retaining the title they won on home soil of the competition designed exclusively for home-based players.
The Atlas Lions, who had come under pressure from their fans for their unimpressive showing in their first two matches of the tournament, took charge of the game by dominating the early exchanges.
They had several scoring chances to open the scoring in the opening 20 minutes but striker Ayoub El Kaabi missed three decent chances while goalkeeper Charles Lukwago was also in top form to prevent the champions from breaking the deadlock.
Against the run of play Uganda opened the scoring in the 25th minute with Orit taking advantage of some sloppy marking to fire home with goalkeeper Anas Zniti completely beaten.
The Moroccans continued to miss decent scoring opportunities as with Al Kaabi, Reda Jaadi and Soufiane Rahimi all getting opportunities to beat Lukwago who was alert.
The Atlas Lions were not to be denied just before the break when defender Mustiafa Mujuzi handled the ball in the box.
El Kaabi made no mistake by sending Lukwago the wrong way to restore parity and make history by becoming the first person to score 10 goals in the CHAN competition.
The striker scored nine goals in the previous competition in his home country and by plundering his first goal of this tournament he wrote himself into the history books.
The Moroccans returned from the break determined to win the match and Adam Ennaffati took charge of tormenting their opponents from the right wing.
Ennaffati combined with Rahimi to give the title holders the lead just six minutes after the break before a goal by Hamza El Moussaoui in the 71st minute made it 3-1.
The Atlas Lions continued to pile the pressure and Rahimi got his second of the match when Al Kaabi’s bicycle kick accidentally fell to him before the midfielder fired past Lukwago.
Set piece specialist Saidi Kyeyune’s free-kick just outside the goal in the 84th minute beat goalkeeper Zniti to revive the faint hopes of the Cranes.
But Abdellilah Hafidi’s effort went in via goalkeeper Lukwago to put the game beyond the Cranes and seal Morocco’s place at the top of the group.
The Altas Lions will play the second-placed team in Group D in the quarter-finals to be played at the the Stade de la Réunification in Douala on Sunday.