Egypt secured top spot in Group C at the Paris Olympics with an impressive 2-1 victory over Spain on Tuesday in their final group stage match.
Man of the match Ibrahim Adel netted a brace in the 40th and 62nd minutes, while Samu Omorodion scored a late consolation goal for Spain in injury time.
The young Pharaohs finished with seven points from three matches and will face the runners-up of Group D, which includes already-qualified Japan, along with Paraguay, Mali, and Israel.
With their quarter-final berth already secured, Spain rested several key players, a decision they may now rue given the match's outcome.
Rogerio Micale's side showed significant improvement from their previous two games, putting the Spanish keeper under pressure from the opening stages.
Adel had two early attempts blocked, while a powerful shot from Ahmed "Koka" Nabil was parried away for a corner.
In the 40th minute, Ahmed "Zizo" El Sayed made a surging run and set up Adel, who finished with a superb strike from the edge of the box.
Spain coach Santi Denia made several substitutions at halftime in an effort to regain control, but Egypt's confidence continued to grow.
Adel capitalized on a defensive error to double Egypt's lead, racing clear and slotting the ball past the keeper.
Koka, Adel, and Atef all missed further chances to extend the lead against a Spanish side pushing forward and leaving gaps at the back.
Omorodion headed in a late goal, exploiting a rare lapse in concentration from the Egyptian defense.
Check Team Egypt squad
Check Team Egypt schedule and results
(For more sports news and updates, follow Ahram Online Sports on Twitter at @AO_Sports and on Facebook at AhramOnlineSports.)