Title holders Morocco reached the quarter-finals 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.
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.