Rob Page’s side produced a mostly dismal display at Ahmad bin Ali Stadium in Al Rayyan on Friday, with dominant Iran twice hitting the woodwork and forcing Wayne Hennessey into a couple of huge saves.
However, Hennessey’s late red card - awarded after a VAR review - for inexplicably racing out of his box and clattering Mehdi Taremi proved a crucial turning point, with 10-man Wales unable to hold on courtesy of last-gasp efforts from Roozbeh Cheshmi and Ramin Rezaeian.
The result boosts Iran’s hopes of reaching the last-16 for the first time, while Wales now need to beat old rivals England on Tuesday night.
Here is how the Wales players rated on Friday...
Wayne Hennessey - 4
Made one good save to keep out Saeid Ezatolahi but was sent off after totally misjudging a through-ball and clattering into Mehdi Taremi.
Chris Mepham - 6
Like Rodon too often having to put in last-ditch challenges and headers.
Joe Rodon - 6
Another player guilty of poor distribution, in his case Hennessey saved his skin by saving low from Saeid Ezatolahi.
Ben Davies - 7
Some important blocks, and almost scored with a rocket of a shot in the second half which was brilliantly kept out by Iran goalkeeper Hossein Hosseini.
Connor Roberts - 5
Almost gifted Iran the lead in the first half with a dreadful pass inside, with only VAR saving him. Distribution and decision-making questionable.
Neco Williams - 6
Failed to take advantage of a decent first-half opening which could have changed the shape of the game.
Ethan Ampadu - 5
A bad afternoon for the Spezia player, with his passing letting him down in central midfield.
Aaron Ramsey - 5
Never got a grip on midfield and poor with his distribution and set-piece play.
Harry Wilson - 7
One of the more impressive figures in midfield, had one good effort deflected over.
Kieffer Moore - 6
Worked hard up front with little reward.
Gareth Bale - 5
Extremely quiet by his high standards, and was hardly in the game at all.
Dan James (for Wilson, ‘58) - 6
Sparkled initially when he came on but by the end was also misplacing passes.
Brennan Johnson (for Roberts, ‘58) - 6
Provided more attacking threat than Roberts, but ultimately failed to make a telling impact.
Joe Allen (for Ampadu, ‘77) - 5
His poor clearance led to Iran's first goal in the 98th minute.
Danny Ward (for Ramsey ‘87) - 6
Could do nothing about the two goals he conceded.
Additional reporting by the Press Association.