Younes Belhanda headed past the post from Nordin Amrabat's cross shortly after as Morocco found their way behind the Iran defence easily, before Ayoub El Kaabi failed to test Alireza Beiranvand in the Iran goal when he swung wildly at a chance from 18 yards.
FIFA World Cup 2018 Schedule in IST for PDF Download: Fixtures, Groups, Time Table with Match Timings & Venue Details of Football WC in Russian Federation.
Morocco impressed in qualification and only conceded one goal as they made it to the tournament in Russian Federation.
The former Cambridge United manager - the second ex-U's boss to manage at the World Cup in the past 20 years - masterminded Morocco to the biggest upset of African qualifying as they topped their group ahead of his former team, Ivory Coast.
Carlos Queiroz, who is the first coach in Iran to take the team to the World Cup twice, knelt down to celebrate the goal at the match.
Aziz Bouhaddouz of Morocco (not pictured) scores an own goal past Monir El Kajoui for Iran's match-winning goal in stoppage time.
Morocco are appearing in their first World Cup finals since 1998.
The King of Morocco, King Mohammed VI, has already instructed his country to try again and bid to host the 2030 event, while a strong World Cup showing in Russian Federation would help raise the profile of the team.
In a group where Spain and Portugal are strong favourites to qualify for the knockout stage, the outcome gives Iran an outside chance of an upset but was a bitter blow for an enterprising Moroccan side.
Morocco: Mohammed - Hakimi, Benatia, Saiss - Siah, El Ahmadi - Boussoufa, Harith (Da Costa, 82) - N. Amrabat (S. Amrabat, 76), Al-Kaabi (Bouhaddouz, 76), Belhanda.
Morocco are now on a run of 18 games unbeaten, a vein of form that is only bested by Belgium (19) and Spain (20) going into Russian Federation 2018.
He said: "We must already focus on Iran".
As such, Queiroz views the contest against the Moroccans as a must-win game.
But the chance was wasted as Azmoun did not show enough composure with Mohamedi denying him and also saving the follow-up attempt from Alireza Jahanbakhsh. "They just want to express themselves and play football".
"In a competition you have three matches to play and we still have two matches left".
With Morocco not conceding a goal in its final round of qualifying for the World Cup, plus Iran keeping nine-straight clean sheets in their 10 qualifying games, a tight game was to be expected and that's how it turned out. Until the 94th minute, the two teams were pitched in a sluggish, even-handed standoff that looked destined for a 0-0 draw.
82% of the total shots in this match (18 of 22) came in the first half.
This was the first victory by an Asian team against an African team in the World Cup finals since Japan won 1-0 against Cameroon in June 2010.