Morocco and Zimbabwe went through to the last eight at the African Nations Championship after the final round of Group B matches.
Uganda went into Monday's games top of the group but a 3-1 defeat to Morocco saw the Atlas Lions accumulate five points, one more than the Cranes.
And Zimbabwe also qualified with five points by beating Burkina Faso 1-0.
It was Zimbabwe's first goal of the tournament and sent them through behind Morocco on goal difference.
The Warriors had previously managed only two 0-0 stalemates with Morocco and Uganda but they edged their way into the knockout stages of the competition in South Africa thanks to a 57th-minute effort from Masimba Mambare.
The striker got in front of Burkina Faso keeper Mohamed Kabore to head in from Peter Moyo's cross to give his side a lead they held on to quite comfortably.
Morocco's place in the next round looked in doubt until the 78th minute of their match with Uganda.
Abdessamad Rafik had put Morocco ahead when he turned in a low cross from six yards and although Yunus Sentamu levelled on 60 minutes after a neat one-two with captain Dennis Iguma, a point would not have been enough for Uganda.
But with 12 minutes left Mouhssine Iajour (pictured) put Morocco ahead with a low finish from the edge of the area.
El Ouadi sealed the victory - and his side's progress - in stoppage time when the winger collected a rebound and rounded the keeper to slot home.
Morocco will face Nigeria in the quarter-finals, while Zimbabwe will take on Mali.