Group leaders Australia face third-placed Saudi Arabia in Jeddah later on Thursday.
Four-times Asian champions Japan took the lead in the 26th minute through Genki Haraguchi, who capped off a flowing Japanese counterattack with a sublime back-heel finish through his own legs from Hiroshi Kiyotake's near-post cross.
Iraq were causing Japan all sorts of problems from set pieces and got back on level terms when Saad Luaibi rose highest to nod home Ahmed Yaseen's free kick with an hour gone.
Japan piled forward in the closing stages in search of the winner and were rewarded when Yamaguchi hammered home a loose ball deep into stoppage time.
The top two sides in Group A and B qualify for the World Cup in Russia while the third-placed teams meet to decide who goes into a CONCACAF-Asian Zone playoff for a place at the finals.
(Writing by Peter Rutherford; Editing by Pritha Sarkar)