Japan beat Indonesia 3-1 in their final Asian Cup Group D game on Wednesday to guarantee a top-two finish and qualify for the last-16.
Iraq went top with maximum points when they sealed a 3-2 win over Vietnam with a 102nd-minute winner.
Japan's Ayase Ueda scored twice for Hajime Moriyasu's side, who finished second with six points, while Iraq's Aymen Hussein went top of the tournament's scoring charts with his fourth and fifth goal.
Japan took a 1-0 lead when they won a penalty in the second minute after Ueda was hauled down in the box by Jordi Amat, with the spot kick awarded after a VAR check. Ueda stepped up to take it himself and he fired home into the top corner.
The lead was doubled when Ritsu Doan put in a pass across the six-yard box that found Ueda unmarked at the far post for an easy tap-in. Ueda then forced an own goal in the 87th minute when Justin Hubner attempted to block his shot.
Indonesia scored a consolation goal in added time when Japan failed to clear a long throw-in and the ball fell to Sandy Walsh at the far post where he finished smartly for his first international goal.
In the other Group D game, Vietnam took the lead just before halftime when Bui Hoang Viet Anh scored from a set piece but Khuat Van Khang was sent off for a second yellow at the stroke of halftime.
Iraq equalised two minutes after the restart when Rebin Sulaka headed home from a corner before Hussein scored with a header of his own in the 73rd minute.
Vietnam nearly stole a point in added time when Nguyen Quang Hai equalised in the 91st minute but Iraq earned a penalty which was calmly converted by Huessein in the 12th minute of added time.