Soo-yun Kim scored the winner in the 78th minute to cap South Korea's 2-1 comeback over Spain Wednesday night at Ottawa, Ontario, to reach the knockout stage of the Women's World Cup.
Sonia Bermudez's free kick in the fifth minute of stoppage time hit the crossbar and went over the net, ending the game and Spain's (0-2-1) first-ever World Cup appearance.
South Korea (1-1-1) finished second to Brazil in Group E and will play France on Sunday in the round of 16.
Kim floated her shot from the just outside the penalty box and over the hands of diving goalkeeper Ainhoa Tirapu. South Korea tied it when Yu-mi Kang passed the ball over three defenders to team captain So-hyun Cho, who headed in the equalizer in the 53rd minute.
Spain's Veronica Boquete scored her only goal of the tournament in the 29th minute.
Spain controlled the first half, not allowing South Korea any shots on goal.