Sandar Azmoun, Morteza Pouraliganji and Reza Ghoochannejhad scored for Iran while Ahmed Yasin, Ahmed Yasin and Dhurgham Ismail got the goals for Iraq.
Both teams scored two goals in extra-time after the 90 minutes ended with the teams tied at 1-1.
In the 24th minute Azmoun opened the scoring for Iran with a header,
Just before half-time Mehrdad Pouladi was sent off when he was booked for a second time.
Ahmed equalised for Iraq in the 56th minute with the goal that would send the match to extra-time.
Iraq then scored early through Younis Mahmoud to go into the lead.
Ten minutes later Morteza got the equaliser for Iran only for Dhurgham to score with a penalty kick in the 116th minute to take Iraq to a 3-2 lead.
Iran’s Reza did the impossible and scored for his side when he got the ball into the back of the net after a goalmouth scramble to take the match to a penalty shoot-out.
The drama continued in the shoot-out, with the first two penalties from Iran's Ehsan Hajysafi and Iraq's Saad Abdulameer missing completely.
The rest of the penalties were all perfect until Iran's Vahid Amiri hit the post to miss.
Salam Shakir calmly scored with his penalty kick to secure Iraq the 7-6 win and a semi-final berth.