Rouzbeh Cheshmi and Ramin Rezaeian both scored in stoppage time to secure Iran a famous 2-0 World Cup win over Wales and keep their hopes of reaching the last 16 alive in stunning fashion.
Wales, who had Wayne Hennessey sent off late on, had seemingly been on course to somehow avoid defeat, but two fine goals right at the end sparked bedlam among the Iran team and fans.
Iran opting to sing their national anthem after abstaining against England contributed to a charged atmosphere that brought an early flurry, including a disallowed Ali Gholizadeh goal.
That let-off and the fact Gholizadeh and Sardar Azmoun struck the post just after the break suggested luck was on Wales' side.
But Hennessey's red card for a wild challenge turned the tide, and Iran picked the Dragons off in ruthless and remarkable fashion.
A lively start saw Connor Roberts almost inspire an early Wales opener for Kieffer Moore with a brilliant cross, before seeing then his poor pass lead to Gholizadeh finishing off an intricate move.
Fortunately for Roberts, the goal was disallowed for offside and the contest soon became cagey.
Iran finished the first half well and maintained that greater purpose at the start of the second, with Azmoun smashing against one post on the break and Gholizadeh curling against the other nine seconds later.
Wales became even less of a threat as Hennessey was given his marching orders in the 86th minute after racing out of his goal and catching Mehdi Taremi in the face with his knee.
Iran took full advantage when Cheshmi's emphatic 20-yard strike into the bottom-right corner finally gave them the deserved breakthrough, and Wales were finished off on the break.
Taremi charged forward and coolly picked out the run of Rezaeian, whose delicate finish over Danny Ward ended Wales' hopes of a turnaround.