Brisbane: Morocco defeated Colombia 1-0 on Thursday to advance to the round of 16 at the expense of two-time champions Germany thanks to Anissa Lahmari's winning goal.
The unexpected result in Perth gave Morocco six points, and on the basis of goal differential, they came in second place to Colombia in Group H.
After being held to a 1-1 tie in Brisbane by South Korea, Germany was eliminated.
In the round of 16, Morocco will take on France and Colombia will play Jamaica.
It was a fairytale outcome for Morocco, who had defeated South Korea and Colombia after suffering a crushing 6-0 loss to Germany in their debut match.
Ibtissam Jraidi was impeded in the box by a careless Daniela Arias just before halftime in front of 17,342 spectators, leading to the game's lone goal.
Goalkeeper Catalina Perez made a fantastic stop on Captain Ghizlane Chebbak's penalty kick with a lunging move to her left.
On the deflection, though, Sakina Ouzraoui pounced, and her deft ball found Lahmari, who shot perfectly from close range.
Even though they had already essentially advanced to the round of 16, Colombia, sporting their trademark yellow uniforms, fielded a full lineup.
After x-rays revealed she was healthy, Real Madrid striker Linda Caicedo took her spot. Caicedo was 15 when she was diagnosed with ovarian cancer but has now made a full recovery.
Caicedo, who scored in Colombia's victories against South Korea and Germany, had breathing problems against Germany just a few days after collapsing in practice due to chest trouble.
Mayra Ramirez, a midfielder, recovered from a knee injury incurred against Germany.
However, Morocco heeded the coach's advice to play energetically, as a dashing Jraidi forced Perez to make a save in the first minute.
Early exchanges were still governed by an attacking Morocco, with Chebbak and Fatima Tagnaout being especially significant.
Lahmari's long-range attempt on the hour flew well past the bar after being set up by Tagnaout.
Caicedo made little of an effect and took a careless tackle to the foot that left her writhing on the turf.
Just before halftime, she finally got involved with numerous threatening sprints down the right, but Colombia was unable to take advantage.
Lahmari's goal for Morocco made them pay by leaving the team on thin ice going into halftime.
As Colombia came out aggressively and came close to tying the score, Daniela Montoya's shot was excellently stopped by Moroccan keeper Khadija Er-Rmichi on the hour.
Ramirez sent a strong shot into the right post from a tight angle as they kept up the pressure.
But Morocco held on, causing their players to erupt in wild celebration.