Goals from Edin Dzeko, Miralem Pjanic and Avdija Vrsajevic restored some pride after a hugely disappointing tournament for the Bosnians, whose elimination had already been confirmed following defeats to Argentina and Nigeria.
Iran, for whom Reza Ghoochannejad scored, needed to win the Group G game and hope Nigeria lost to Argentina in Porto Alegre, which they did 3-2, to maintain their hopes of reaching the last 16.
Having failed to score in their previous two matches — a 0-0 draw with Nigeria and 1-0 defeat to Argentina — Iran never looked likely to cause a surprise by beating Bosnia.
Dzeko opened the scoring halfway through the first half as he was given time and space to take a couple of touches, line-up his sighter from distance and fire a sizzling low strike inside goalkeeper Alireza Haghighi’s left-hand post.
Pjanic seemed to have settled the affair 11 minutes into the second half after running on to Vedad Ibisevic’s pass to fire home confidently.
Iran pulled a goal back inside the last 10 minutes when Ghoochannejad slotted home at the back post.
But within 60 seconds Vrsajevic had scampered up the pitch from right back to fire across Haghighi and extinguish any Iranian hopes.
It meant the Bosnians, in their maiden World Cup, finished third in the group and can go home with some solace after the disappointment of elimination before the final match was even played.
Iran finished bottom with one point.