Japan lost to Poland but qualified for the World Cup round of 16 by virtue of a better disciplinary record than Group F rivals Senegal.
On an incredible final day in the group stage, Japan looked to be heading home after Jan Bednarek's 60th-minute opener for Poland in Volgograd. That would have put them out, but Japan coach Akira Nishino -- who made six changes to his lineup -- was indebted to Yerry Mina's goal in Colombia's win over Senegal.
Mina's strike meant Japan and Senegal's Group F records were identical. Fair play -- which was only introduced as a tiebreaker at this year's World Cup -- was then used to split the pair, with Japan's four yellow cards beating Senegal's six. Japan, therefore, reached the round of 16 along with Colombia, with England or Belgium lying in wait.
Coach Nishino took a risk with his team selection ahead of the defeat to Poland, resting the four players to have scored for Japan at the tournament so far, including star man Takashi Inui.
Japan lacked their usual fluency and Eiji Kawashami's superb sprawling save from Kamil Grosicki was the highlight of a dour first half, with goalline technology confirming the header did not cross the line.
The second half then gave way to high drama, as Poland's Rafal Kurzawa floated a free kick to the far post and an unmarked Bednarek volleyed home 30 minutes from time, putting Japan out as things stood.
Robert Lewandowski then skied the ball over from inside the area as Japan stood on the brink of elimination.
And yet, incredibly, they escaped. Mina's strike for Colombia on 74 minutes in the other match sent the group decider to fair play, with both final games ending 1-0.
With both Japan and Poland happy with the result, their game petered out in the dying minutes in farcical circumstances, withe the already-eliminated Poles content to let the Japanese play keep-ball in their own half.
That worked in Japan's favour despite their loss, with Nishino breathing a sigh of relief as they became the only Asian side to progress to the knockout stage after a nail-biting end to Group F. Colombia, meanwhile, ended the day as group winners.
Information from Reuters was used in this report.