Striker Walaal Musa was the hero for Sudan as his goal on the half hour mark booked their place in the quarters thanks to a 1-0 win over a spirited Mauritania side.
The victory saw the Desert Hawks qualify for the last eight joining host Morocco who had earlier beaten Guinea 3-1 at the same venue in Casablanca.
Corentin Martins' chargers started the better side as Hameya Tanjy headed El Mostapha Diaw's inviting cross over the Sudan goal with eleven minutes on the clock.
Mauritania came close again from a set piece Sidi Mohamed Bilal stabbing wide Alassane Diop's curling effort .
Babacar Bagili pounced on a misplaced back past in the Sudanese back but he couldn't beat the rushing keeper and wasted the opportunity muvh to the frustration of manager Martins.
Walaal Musa punished the wasteful Mauritanians with a clinical stylish finish from captain Mohamed Tahir's delightful assist.
Moulaye Ahmed Khalil found space on the right but his near post cross was cleared just wide of Akram Abdeltam's goal by towering defender Omer.
Sudan hang on to secure their second win of the tournament and book a place at the quarters, their first since 2011 when they hosted the tournament.
Morocco and Sudan have six points each with Guinea and Mauritania pointless in that order.
Logarusic Zdravko Hrvatsko (Head Coach, Sudan)
I must congratulate Mauritania because they also have their chances but could not take it. Sometimes you have to be lucky a bit so we're lucky to be facing Morocco in the last game. My target is the next game so let me enjoy this moment.
We're not here as tourist; we came here to compete so let's see what will happen in next game.
Corentin Martins (Head Coach, Mauritania)
On Saturday I was disappointed with my forwards but today I cannot blame them. Tonight, it was a competition and that will not change against Guinea because we have defend the Mauritanian flag. We did not refuse to play football; we did play and you can see we created chances.
Some of our players have done well in this tournament which will help them move on.