With the two sides tied on points and goals heading into their final matches, each required only a point to be sure of a place in the next round.
In bizarre circumstances, though, Japan went down 1-0 to already eliminated Poland as Senegal lost by the same scoreline to Colombia.
With Colombia climbing to the top of the group, yellow card rankings were required and Japan came out on top, having only been cautioned four times to Senegal's six.
Japan, knowing this outcome, opted not to attack in the closing stages and instead gambled on Senegal not scoring in Samara.
FIFA introduced this method of separating teams for the 2018 tournament, with the drawing of lots the next step if Japan had picked up another two yellow cards in Thursday's match.
Group H came down to the finest of margins. #JPN go through ahead of #SEN, with the Lions of Teranga eliminated on Fair Play points. pic.twitter.com/YCDk0hSWmL
— FIFA World Cup (@FIFAWorldCup) June 28, 2018
Photo Getty Images. Caption: Japan celebrate their bizarre qualification