It was a mouth-watering repeat of the Beijing 2008 final. Mirzet Duran and Safet Alibasic have been in great form for Bosnia and Herzegovina throughout the tournament, while Davood Alipourian and Isa Zirahi have stood out for Iran.
Iran were more clinical in the opening set, taking it 25-19, but their opponents responded by edging the next two sets to move within one of victory.
The fourth set was all Bosnia and Herzegovina as they raced into an 18-13 lead and held on to claim a memorable victory.
Nizam Cancar and Zirahi finished the match as joint top-scorers with 15 points each.
Bosnia and Herzegovina's Sabahudin Delalic said afterwards: 'After we lost the first set we realised that the only way for us to win was to attack only. That's how we tipped the balance.'
Earlier in the day, Germany overcame Russia 3-2 (20-25, 26-24, 22-25, 25-22, 16-14) to win the bronze medal in a thrilling encounter.
Russia claimed the first set, with Alexander Savichev in excellent form, but the second was more dramatic. Scoring was evenly matched throughout, however, Germany capitalised on their first set point.
The next two sets were shared, setting up a thrilling decider, and the scoring remained even with the two sides locked together at 13-13.
But it was Germany who held their nerve to edge it, and Jurgen Schrapp said: 'It is unbelievable. It is a dream we have had for so long and we have made it. It was an unbelievable game and we managed to turn it around. We have a crazy team and we deserve it.'