Iran had come out fighting in the second half and hit the post twice in a matter of seconds
Iran scored twice in the final moments of stoppage time to keep alive their hopes of reaching the World Cup knockout stages for the first time with a thrilling last-gasp victory over a stunned 10-man Wales.
Wales, who had keeper Wayne Hennessey sent off late in the match, looked to have survived the Iranian onslaught in their Group B encounter at Al Rayyan's Ahmad Bin Ali Stadium, before substitute Rouzbeh Cheshmi found the net and Ramin Rezaeian sealed the win with seconds left.
Iran had come out fighting in the second half and hit the post twice in a matter of seconds, with Sardar Azmoun's shot rebounding to Ali Gholizadeh, whose follow-up cannoned off the upright and back to the waiting Azmoun, who headed tamely into keeper Hennessey's hands.
Iran, whose World Cup squad has been distracted by a political crisis at home, came close again on 72 minutes when Hennessey got a fingertip on Saeid Ezatolahi's shot.
They then piled on the pressure after Hennessey was sent off for dangerous play when he charged out of his area and clattered into the onrushing Mehdi Taremi.