The rank outsiders in a group also containing Spain and Portugal were set for a 0-0 draw of little use to either until Ehsan Hajsafi curled in a free-kick from the left wing which Bouhaddouz tried to intercept at the near-post but instead steered it into the goal.
It was heart-breaking for Morocco, making their first finals appearance for 20 years, but after starting brightly they will rue their cautious second half display.
Morocco keeper Munir Mohamedi had earlier made a smart double save to deny Sardar Azmoun's sharp shot and Alireza Jahanbakhsh's looping follow-up while Iran keeper Alireza Beiranvand also had to stay alert when he went full length to touch away Hakim Ziyech's low volley.
Morocco's Aziz Bouhaddouz scores an own goal
Add commentComments will be edited (grammar, spelling and slang) and authorized at the discretion of Daily Mirror online. The website also has the right not to publish selected comments.