Asian Cup: Iran 3 Iraq 3 (pens 6-7)
Iraq - winners of the tournament in 2007 - will now play South Korea on Monday, with a spot in this year's final up for grabs.
Friday's match in Canberra was impacted significantly by referee Ben Williams, but the stunning nature of the encounter ensures it will be remembered as one of the best ever played at the tournament.
Both sides made a stuttering start to the shootout, as Iran's Ehsan Hajsafi and Iraq's Saad Abdulameer missed the target.
The next 12 penalties were scored, though, including a Panenka from Iraq captain Younis Mahmoud at 4-3 when a miss would have eliminated his side. Mahmoud's bravery was made more amazing by the fact he missed a similar penalty in his side's 2-0 win over Palestine on Tuesday.
Iran's Vahid Amiri then hit the post, allowing Shakir to slot to his right and secure Iraq's progression.
Earlier, Sardar Azmoun's header gave Iran a 24th-minute lead, before Williams, who was criticised heavily by Iran boss Carlos Queiroz earlier in the tournament - leading to the ex-Real Madrid coach being fined - sent Mehrdad Pooladi off in bizarre circumstances just two minutes before half-time.
Pooladi, earlier booked for a late challenge on Ahmed Yasin, made minor contact with Iraq goalkeeper Jalal Hassan Hachim when chasing a loose ball. The keeper then shoved Pooladi, who theatrically fell to the ground holding his face, leading to another booking from Williams.
The Australian official forgot that he had already carded Pooladi, but upon being reminded by several Iraq players, produced a red card that seemed incredibly harsh.
Iraq made the man extra count in the second half, when, after a spell of pressure, Yasin fired in from a tight angle 11 minutes after the restart, and after an additional 30 minutes was forced, Mahmoud headed them in front.
Iran climbed off the canvas, though, with Morteza Pouraliganji's thumping header bringing them level in the 103rd minute, but the defender then brought down Yaser Kasim in the area to concede a penalty - scored by Dhurgham Ismail in the 116th minute.
The drama, amazingly, did not end there, as an Iran corner - which was initially cleared off the line, before Andranik Teymourian fired against the crossbar - was finally nodded in by substitute Reza Ghoochannejhad in the 119th minute.
That brought about penalties but it was to be Iraq's night in the Australian capital.
Pooladi was booked for the first time in the 22nd minute, before Azmoun opened the scoring with a bullet header from Vouria Ghafouri's cross.
Williams then gave Pooladi his marching orders, leading Queiroz needing to be restrained by his players at half-time as tensions threatened to boil over.
Yasin levelled for Iraq early in the second half, thrashing in a low and hard effort from an acute angle - via a slight Pouraliganji deflection - after Alaa Abdul-Zahra's teasing ball across the face of goal.
A string of fouls, substitutes and injury concerns stopped the flow of the game, but once extra time arrived, Iraq quickly had their second goal.
Ismail and substitute Ali Adnan linked well down the left, allowing the former to storm into the box, and his shot took a pair of deflections before falling kindly for Mahmoud - with Hajsafi helpless on the line.
Iran dug deep, though, and equalised when Teymourian's swinging corner was powerfully headed in by defender Pouraliganji.
The match seemed surely over when Pouraliganji brought down Kasim, and 20-year-old Ismail showed nerves of steel to score, yet somehow, Iran conjured up another equaliser as Ghoochannejhad nodded in to end a goalmouth scramble.
An on-field scuffle broke out as penalties approached, after Marwan Hussein was booked for fouling Haghighi, but that mattered little in the end, as Iraq celebrated a truly famous win.