The defeat, which also saw goalkeeper Wayne Hennessey sent off for a rash challenge, leaves Wales needing to beat England in the Group B decider.
Captain Gareth Bale, who became Wales' most capped men's player with his 110th appearance for his country, said, "Every Welsh fan will be proud of us for giving 100% on the pitch."
Many of the Red Wall remained to cheer on their national side after the final whistle and a chorus of ‘Yma o Hyd’, the team’s official World Cup song, rang out as players left the pitch.
Others said they felt for manager Rob Page after witnessing his family in tears at the end of the match.
Despite the “disappointment” some insisted Wales could still “smash” England in the third and final game in the group stage.
After the game, Bale told said, “We are gutted, there is no other way to say it. We fought until the last second and we need to go again.
"It was disappointing obviously that the sending off gives them an extra man when we're tired in the last ten minutes. Not that it's Wayne's fault at all, he had to come out and do what he did. "We would never blame anyone. But it's difficult to take conceding so late.
"It's still raw, it's still difficult to look back on."
Wales coach Robert Page admitted his team had fallen well below the standards they set for themselves as they teeter on the brink of World Cup elimination.
The side are due to take on England on Tuesday and simply need to win to stand a chance of qualifying out of their group.
England is hoping for a victory against the USA tonight which would see them make it to the last 16.
Page even appeared to refer to the England game as Wales' "final" match of the tournament, underlining how difficult the road ahead is for the Dragons from here.
"This is a hard one to take," Page said. "I've said to them before every game: 'Go and show the world what you show us every day,' and that is not a true reflection of that team.
"They got their true rewards today, they deserved that defeat. We fell well below the standards that got us to the World Cup, if we'd met those standards we'd have been alright. And if you do that in top competitions, you get punished."
Full match report by ITV Wales sports reporter Matthew Southcombe
The early signs were promising with Kieffer Moore linking up nicely with Harry Wilson in the opening minutes to work an opening for a Neco Williams shot that ended up the wrong side of the post.
Iran also started brightly, though, and worked chances of their own in the opening exchanges, with the Welsh defence having to scramble on more than one occasion to snuff out threatening attacks.
The game’s first big chance fell to Moore in the 12th minute. Connor Roberts worked some space down the near side to whip a brilliant cross into the middle and the striker got his outstretched right boot to it but it went straight at Hossein Hosseini in the Iranian goal.
It then appeared as though disaster had struck for Wales when Ali Gholizadeh rolled the ball beyond Wayne Hennessey, only for VAR to come to the rescue and rule the goal out for offside.
The best Wales could muster for the rest of the half was a deflected Harry Wilson shot but they had not displayed anywhere near the level of control that had been expected of them in what was a tense opening 45 minutes.
Five minutes into the second half and Wales were hanging by a thread. Sardar Azmoun was put through on goal but his effort cannoned off the post. Seconds later, Gholizadeh’s curling effort from outside the box then hit the other post, with the rebound falling into the open arms of a relieved Hennessey. Almost immediately, Page turned to his bench in an effort to stem a tide that was undoubtedly flowing against his side.
As the game ticked into the final half hour, both sides created half chances as Wales threw caution to the wind, putting on attackers Dan James and Brennan Johnson, which really opened the game up, making it an end-to-end affair.
In the 72nd minute, Iran went close again when a scuffed shot from Saeid Ezatolahi forced a good save from Hennessey, who got down low to his right to tip the ball around the post.
With minutes remaining, Ben Davies - of all people - forced a decent save out of Hosseini with a drilled shot from outside the area.
Things then went from bad to worse for Wales when goalkeeper Hennessey was shown a red card for clumsily clattering into Mehdi Taremi as he attempted to clear a ball that was sent over the top of the Welsh defence. Replacement goalkeeper Danny Ward then came onto the field for Aaron Ramsey.
But, after 98 minutes, Wales were put out of their misery. The ball fell to Roozbeh Cheshmi on the edge of the box and he curled a superb effort beyond the outstretched Ward to put his side 1-0 up.
Wales then threw men forward in a desperate attempt to equalise in the closing moments but Iran broke and nobody was home to prevent Ramin Rezeian from doubling his side’s lead.
Here was the line up for both sides:Wales: Hennessey; Mepham, Rodon, B Davies; Roberts, Ampadu, Ramsey, Wilson, N Williams; Bale (C), Moore.
Subs: Ward, Davies, Gunter, Allen, Johnson, Lockyer, J. Williams, Harris, James, Thomas, Levitt, Cabango, Colwill, Smith.
Iran: Hossein; Rezaeian, Pouraliganji, M. Hosseini, Mohammadi; Gholizadeh, Noorollahi, Ezatolahi, Hajisafi (C); Taremi, Azmoun
Subs: Beiranvand, Niazmand, Abedzadeh, Moharrami, Khalilzadeh, Jahanbakhsh, Ansarifard, Amiri, Kanani, Ghoddos, Cheshmi, Torabi, Karim, Jalali
Iran, ranked 20th by FIFA, have competed in five World Cups before but never made it through the group stages.
They had only met on the grass with Wales once before, at an international friendly in Tehran in 1978, where Wales secured a 1 -0 victory.
The Iranian players were seen joining in their national anthem after after choosing to stay silent during their opening game against England last week, as a show of support for the protest movement taking place in the country.
There had been reports that several fans travelling from Dubai to the match on Friday faced visa problems at the airport and risk missing the game.
The Wales Football Supporters’ Association said on Twitter: “Loads (of visas) finally got approved late but this whole process with day permit for Iran game has been difficult for our fans.
“We have informed Fifa and FAW.”
Dozens of fans replied to the post saying they or other supporters had been affected.
Fans with a valid match ticket are able to apply for a Matchday Visit Hayya Card, which is a visa permit that allows entry into Qatar for up to 24 hours.
However, many had reported that they were not being issued in time to board the shuttle flights into Doha.
Elsewhere before the game, hundreds of Wales fans in Doha had gathered at the bucket hat corniche on Friday morning as part of a 'pop-up' pre-mach party.
Dafydd Iwan, The Barry Horns, the Urdd choir and plenty of supporters met for a singalong gig before heading off to the stadium.
A sea of red shirts and bucket hats could be seen on the city’s waterfront on Friday, with the crowd belting out fan favourites including Yma O Hyd, I Love You Baby, and the Welsh national anthem.