RUSTENBURG, South Africa (AFP) - Superb free-kicks by Keisuke Honda and Yasuhito Endo inspired Japan to an exhilarating 3-1 win over Denmark that sends them into the last 16 of a World Cup for the first time on foreign soil.
The two first-half strikes set Takeshi Okada's squad on track for a meeting with Paraguay in Pretoria on Tuesday.
Denmark pulled a goal back when skipper Jon Dahl Tomasson netted the rebound from his own penalty after Daniel Agger had been shoved off the ball by Japan's captain, Makoto Hasebe, nine minutes from time.
But substitute Shinji Okazaki wrapped up a famous victory and condemned the Danes to their first group-stage exit from a World Cup.
Needing to win against opponents requiring only a point, Denmark's best period came in an opening quarter of an hour in which they might easily have taken the lead.
Tomasson failed to connect with Simon Poulsen's deflected cross on the edge of the six-yard box and a penalty claim was waved away when, from the resulting corner, Per Kroldrup seemed to be impeded by centreback Yuji Nakazawa as he volleyed wide.
Japan hit back with two chances in quick succession.
Daisuke Matsui was thwarted at close range by Thomas Sorensen's legs before skipper Makoto Hasebe struck a drive fractionally over the angle of bar and post.
Cutting in from the left, Tomasson then saw his attempt to place a shot beyond Eiji Kawashima run inches beyond the far post, just before Japan claimed the lead.
A free-kick conceded 35 yards out did not seem to present a major danger and Honda's shot was not struck with full power.
Sorensen, though, misread it, moving initially to his left before failing to get back across to his right in time to prevent the strike from finding the corner of the net.
The Stoke goalkeeper was at fault on that one but there was little he could do about Japan's second, on the half-hour mark.
Kroldrup was booked for pulling down Yoshito Okubo on the edge of the area and Endo stepped up to dip a David Beckham-esque free-kick over the corner of the wall and just inside Sorensen's left-hand post.
Danish coach Morten Olsen reacted by replacing 34-year-old midfielder Martin Jorgensen with Jakob Poulsen.
But the introduction of younger legs had little impact, with Christian Poulsen's comfortably-saved long-range effort the best the Danes could muster before the break.
Endo came close to claiming his second soon after the restart, when Sorensen misjudged another long range free-kick and was relieved to see the ball find the post after skimming off his fingertips.
Thomas Kahlenberg was unable to control the ball when Tomasson's flick found him unmarked at the back post as Denmark began to pile on the pressure.
Kawashima was able to deal with a fierce 25-yard effort from Jakob Poulsen and a Daniel Agger free-kick and having been beaten by a Soren Larsen volley that came back off the bar, also stopped Tomasson's spot-kick before the forward bundled the ball over the line.
Japan's advantage was restored at the end however. The outstanding Honda turned Dennis Rommedahl superbly in the box and teed up Okazaki for the simplest of finishes.