Kenya finished top of Group A thanks to striker Ryan Ogam's 75th-minute goal in Nairobi.
The home team already had one foot in the knock-out phase heading into the final round of group matches, knowing avoiding defeat would guarantee progress.
Morocco grabbed second place in the group and a last-eight berth courtesy of a 3-1 victory over the Democratic Republic of Congo in a winner-takes-all clash.
Berkane forward Oussama Lamlioui scored in the eighth minute to put Morocco, who were level on six points with their opponents before kick-off, into the lead.
Kenya to face off against Madagascar
The DRC responded through Jephte Kitambala when he fired home for his second goal of the tournament shortly before half-time.
Two-time champions Morocco retook the lead through a Mohamed Hrimat penalty with 20 minutes remaining, before Lamlioui put the game to bed in the 80th minute.
Kenya will face Madagascar in the last eight while Morocco will play co-hosts Tanzania in Dar es Salaam on Friday.