The Netherlands hit Japan with a 90th-minute sucker-punch as Lieke Martens' penalty sent them through to the last eight of the Women's World Cup.
The European champions, on the ropes for much of the final 20 minutes, looked to be heading for extra time when Vivianne Miedema's powerful shot hit the arm of Saki Kumagai at point-blank range.
There was nothing the Japan defender could do about it and the decision by Honduran referee Melissa Borjas felt harsh, but under a set of new laws introduced on 1 June - which includes penalties being awarded for handballs whether intentional or not - it was the correct decision, and the video assistant referee confirmed the award.
Martens converted as the Dutch avenged their defeat by Japan at the same stage four years ago when they made their World Cup debut. They will now play Italy in Valenciennes on Saturday.
Coach Sarina Wiegman said: "We were standing in the circle after the match and we were so happy, yelling at each other.
"We were saying, 'let's continue writing history'. For the first time we got to this stage at the World Cup. All the players then used this mantra."
She added: "We were really struggling in the second half. A lot of that had to with Japan's qualities. That shows how good a team they are."
Japan, whose squad featured 17 players at their first World Cup, may feel hard done to over the penalty, but will also regret not having converted one of several good second-half chances.
The effervescent Yui Hasegawa, whose goal had earlier brought the sides level, missed the far post by inches, Hina Sugita's drive came off the underside of the bar and substitute Yuka Momiki, who was the catalyst for her side's late surge, forced a point-blank save from Dutch skipper Sari van Veenendaal.
They will now turn their attentions to attempting to win gold when they host the Tokyo Olympics in 2020.
The Netherlands controlled the opening moments and took the lead in the 17th minute thanks to some Martens magic.
That woke up the 2011 champions, who moments after the restart were inches from equalising when Yuika Sugasawa's strike came off the post.
However, two minutes before the break Asako Takakura's side were level with one of the goals of the tournament when Hasegawa finished off a slick move with a shot fired high past Van Veenendaal.
Japan's exit means there are no Asian sides in the last eight of the Women's World Cup for the first time in the competition's history.
Their coach Asako Takakura said: "Towards the end of the match in the second half we created many opportunities and it was really unfortunate we couldn't take them.
"I think we lacked the clinical edge. We have to accept the result, we're defeated, we're very disappointed and for all the players I feel very sorry for them and frustrated."