Morocco and Senegal booked their places in the semi-finals of the African U23 Championship even though the hosts lost 1-0 to the West Africans in Friday's game in Tangiers.
Nigeria put a spirited display to thump Algeria 4-1 in Group A's other game in Marrakesh but both sides crash out.
The results mean Morocco and Senegal tied at the top with six points apiece but the latter topped the group on head-to-head record.
Nigeria, runners-up at the Beijing Olympics in 2008, finished third.
Their emphatic victory over Algeria means both sides have three pionts but the Dream Team took the third position on head-to-head record.
Morocco were determined to go forward from the start and after 19 minutes should have scored Andnane Tighadouini contriving to shoot wide from six yards with no one around him.
Senegal also missed from close range with a poor shot from Omar Wade - his blushes were spared a minute later as Abdoulaye Ba's low shot from just out side the area found the back of the net.
Both sides continued to attack after the break Senegal could have doubled their lead but Abdoulaye Sane hurried his shot under no pressure and put it wide from a long ball over the top.
With 19 minutes remaining Tighadouini's effort was spilled by the Senegal keeper Ousmane Mane and the ball somehow spun across the face of the goal and wide.
With news coming in that Nigeria were winning in Marrakesh the Moroccans were happy to waste time and pass the ball around much to the disgust of their fans.
Nigeria got their only win of the competition thanks to a second-half hat-trick by Spain-based midfielder Raheem Lawal.
It was the Algerians who took the lead through Baghdad Bounedjah three minutues before the break but just after the interval Lawal responded with a goal from a free-kick.
The midfielder was fortune with his second goal in the 75th minute as his shot was deflected into the net.
He sealed his hat-trick 11 mintues later before setting up Daniel Uchechi for Nigeria's fourth.
The victory was not enough to see the Dream Team through but clawed back some respect for the struggling giants.
The top three teams at the competition qualify for the Olympics while the fourth-placed side faces a play-off.
The games in Group B take place on Saturday.