Japan through in second spot
Two well-struck goals from free-kicks by Keisuke Honda, after 17 minutes, and Yasuhito Endo, on the half-hour, put them in command before a spirited Denmark revival saw them pull one back through Jon Dahl Tomasson after 81 minutes.
GEAR: Get your Japan WC shirt
Courageous in defence, slick and inventive in attack, Japan then dazzled again and put the contest beyond doubt with a third goal, beautifully created by Honda for substitute Shinji Okazaki with three minutes remaining.
That made sure of second place behind the Netherlands and confirmed their passage to a well-deserved meeting with Paraguay in Pretoria on Tuesday. On this form, they could go further.
"Our team has a strength that some others don't have. All 23 of the players and all of the staff, we are one team together really," said Japanese coach Takeshi Okada.
"We used that strength today and the team worked very hard. I think the players have just started to believe, in a physical way, in what they can do and how far they can go."
Japan dominated the opening half with some exceptional slick, incisive football, their passing and movement at times leaving the Danes looking bewildered and chasing shadows.
But Denmark never gave up and proved that what they lack in speed and skill, they can almost make up for in heart and determination, mounting a second-half revival before bowing out in the group stages for the first time in five finals.
"We are very disappointed, of course," said coach Morten Olsen. "We had the ambition and we believed we could go through.
"I don't think we played that badly and, the way I saw it, it was not a game where we were poor and Japan were good. It was not like that. They had two set pieces and scored."
On a cold night at the Royal Bafokeng Stadium, Japan were in control from the start and stretched the Danish defence with ease.
Their intricate, almost meticulous, one-touch play and the speed of their movement created a series of chances before they took the lead after 17 minutes with a superb goal by Honda.
Taking a free-kick 30 metres out on the right, the blue-gloved striker with bleached hair struck a left-foot shot that faded to the left and away from the flat-footed Danish keeper Thomas Sorensen, who looked helpless.
Denmark tried to exploit their clear height advantage with attempted high crosses, but it was a ploy the Japanese blunted with excellent marking and brave defensive play. Tall striker Nicklas Bendtner, one of three Danes to be cautioned, was easily kept quiet.
Jon Dahl Tomasson shot narrowly wide and had another effort saved, but the Danes wer