Iran had needed to beat Bosnia and hope Nigeria lost to Argentina to keep alive faint hopes of reaching the last 16, but Carlos Queiroz’s side came up well short in the Group F clash.
A powerful strike by Manchester City star Dzeko gave Bosnia an early lead before Miralem Pjanic added a second just before the hour to settle a relatively dull affair at Salvador’s Arena Fonte Nova.
The game burst into life in the final minutes as Iran striker Reza Ghoochannejad netted his side’s first goal of Brazil 2014, but Bosnia replied immediately with an Avdija Vrsajevic goal.
The result confirmed both teams’ exit as Argentina and Nigeria reached the knock-out stages by finishing first and second respectively in the table after the Argentinians’ 3-2 win in Porto Alegre.
Bosnia, whose elimination had already been confirmed prior to the game, are left to rue what might have been after refereeing mistakes contributed to their 1-0 defeat to Nigeria in their previous match.
Safet Susic’s side ended on a high to claim third and leave Iran bottom of the group with a single point from their draw with Nigeria.
Salvador has now seen 21 World Cup goals in four group games after the Netherlands destroyed Spain 5-1, Germany thumped Portugal 4-0 and France dominated Switzerland 5-2 with a last 16 match and quarter-final still to come in the stadium.
Dzeko had the best of the early chances when he fired over after a powerful run into the area, then headed straight at Iran goalkeeper Alireza Haghighi.
His much-threatened goal arrived on 23 minutes when Dzeko unleashed a fierce drive into the bottom right-hand corner past two defenders, which gave Haghighi no chance.
Iran almost hit back immediately as midfielder Masoud Shojaei clattered the crossbar.
But for all of Iran’s attacking efforts, Bosnia’s Stoke City goalkeeper Asmir Bgeovic was solid between the posts, especially from crosses.
With his side 1-0 down at the break, Iran’s Queiroz brought on experienced forward Khosro Heydari to boost their attack.
But Bosnia grabbed the goal which killed off Iran’s hopes from a defensive error.
A poorly timed pass out of the Iran defence was snapped up by Tino-Sven Susic who fed Pjanic and the Roma midfielder drilled his shot home on 59 minutes.
Charlton Athletic striker Ghoochannejad finally got Iran’s first Brazil 2014 goal when he converted a cross eight minutes from time, although replays suggested he was offside.
Bosnia responded immediately to snuff out any hopes of a fight back as right-back Vrsajevic smashed home his shot after a charging run down the right flank.