Morocco have ended Uganda's unbeaten run at the African Nations Championship to top Group B and advance to the last eight of the competition in South Africa.
Hassan Benaicha's side took the lead just before the half-hour mark when Abdessamad Rafik tucked home Abdelkabir El Ouadi's cross from the left.
Uganda, who started the day on top of the group but crash out, equalised on the hour mark when Yunus Sentamu scored his third goal of the tournament from close range.
With the score level, Morocco were set to be eliminated, but late goals from Mouhcine Iajour and El Ouadi saw them past Uganda and through to the last eight, where they will play Nigeria in Mangaung on Sunday.
No Data Analysis info