Japan scored two stunning first-half free-kicks to secure a well-deserved win over Denmark and set up a meeting with Paraguay in the last 16 of the World Cup.
Keisuke Honda smashed his effort into the far corner before Yasuhito Endo, who also hit a post in the second half, curled a fine strike around the wall.
Jon Dahl Tomasson, who missed several earlier chances, followed up his own penalty to pull one back for Denmark after 81 minutes.
But Honda teed up Shinji Okazaki to seal a famous victory for Japan, which ensured they finished runners-up to Netherlands in Group E and reached the second round for only the second time in their history.
It was a performance of confidence and authority from the Japanese which seemed to come from nowhere. Takeshi Okada's side had lost five of their previous six games and only scored nine goals in 12 World Cup matches.
But after a tentative start in Rustenburg, they took the game to the Danes, sparking into life with two efforts in as many minutes. First Daisuke Matsui's clever flick struck the legs of Denmark goalkeeper Thomas Sorensen, and moments later Makoto Hasebe raced into the box but fired narrowly wide.
Denmark went close through Tomasson before a Japan free-kick 30 yards from goal brought about one of the goals of the tournament.
From a straight run-up, in a style reminiscent of Portugal star Cristiano Ronaldo, Honda smashed the ball over the wall and watched it swerve past Sorensen into the far corner.
When Japan won another free-kick shortly afterwards, the Danes were clearly expecting another piledriver from Honda, but instead they watched in horror as Endo's exquisite strike curled around the wall and past the outstretched arms of Sorensen.
While the Danish keeper's positioning could have been better in both cases, Japan's strikes were precise and superbly-executed, making a mockery of the difficulty players have been having with the much-maligned Jabulani ball.
In the space of 13 minutes, the Asian side had doubled the number of free-kick goals we had witnessed in the previous 42 matches at this tournament in South Africa.
Denmark looked stunned by the goals, while an energised Japan kept pouring forward with Endo stinging Sorensen's palms in the closing stages of the first half.
Early in the second, Japan almost scored from yet another set-piece, with Endo's floated strike from 40 yards slipping bizarrely through Sorensen's palms and striking the face of an upright.
While the Denmark keeper appeared all at sea, his opposite number Eiji Kawashima looked confident and commanding, diving at the feet of Tomasson to smother the striker's effort and pushing aside Jakob Poulsen's long-range shot.
Substitute Christian Eriksen fired narrowly over and Soren Larson volleyed against the bar before Danish pressure finally yielded a penalty in the 82nd minute when Daniel Agger was bundled over by Hasebe.
Tomasson's initial shot was easily saved by Kawashima but the ball rolled straight back to the striker, whose scuffed effort only just found the net to bring up his record-equalling 52nd goal in a Danish shirt.
Japan restored their two-goal advantage from a brisk counter attack, with Honda dancing his way into the area and committing Sorensen, before pulling the ball back for Okazaki to tap into the empty net.
Attempts on target
Attempts off target
Projected table based on current scores
|Group A teams||P||W||D||L||F||A||GD||PTS|
|Group B teams||P||W||D||L||F||A||GD||PTS|
|Group C teams||P||W||D||L||F||A||GD||PTS|
|Group D teams||P||W||D||L||F||A||GD||PTS|
|Group E teams||P||W||D||L||F||A||GD||PTS|
|Group F teams||P||W||D||L||F||A||GD||PTS|
|Group G teams||P||W||D||L||F||A||GD||PTS|