Martens gave the Dutch the lead when her backheel from a corner went in via a small deflection off Yuika Sugasawa.
Just before half-time Japan equalised through Yui Hasegawa, who fired in after a brilliant team move.
Hasegawa, Hina Sugita and Yuka Momiki went close before Martens fired in the winner after Saki Kumagai had handled.
The Dutch will now play Italy in Valenciennes on Saturday.
Japan, whose squad featured 17 players at their first World Cup, dominated the final 20 minutes of the match and looked the more likely to win.
The effervescent Hasegawa missed the far post by inches, Sugita’s drive came off the underside of the bar and substitute Yuka Momiki, who was the catalyst for the late surge, forced a point-blank save from Dutch skipper Sari van Veenendaal.
But with minutes remaining of normal time came the bitter blow. Arsenal’s PFA Footballer of the Year Vivianne Miedema, who had a quiet game, smacked an effort goalwards which hit the arm of Kumagai.
Honduran referee Melissa Borjas pointed to the spot before Martens struck home her second and the Dutch winner.