Bosnia beat Iran 3-1 in their Group F finale on Wednesday to record their first World Cup win and deny the West Asians any chance of claiming a shock spot in the knockout stage.
Already eliminated after two losses, Bosnia, appearing at a major tournament for the first time as an independent nation, went ahead in the 23rd minute through striker Edin Dzeko and doubled their lead just before the hour through Miralem Pjanic.
Reza Ghoochannejhad pulled a goal back for Iran in the 82nd minute but any chances of a nervous finish were swiftly put to bed just seconds later when a fine Avdija Vrsajevic strike restored Bosnia's two-goal cushion.
"The win against Iran is scant consolation, but I congratulate my players for a display of commitment and passion against a team needing a win to keep alive their hopes of progressing," Bosnia coach Safet Susic told reporters.
"We lacked experience and cool heads at crucial moments in the opening two games but I cannot complain about effort. That’s just football," adding that he still rued a Dzeko goal wrongly disallowed for offside in a 1-0 defeat by Nigeria.
Iran, whose only World Cup victory came in 1998, had required all three points against Bosnia and a win for Argentina over African champions Nigeria to have any shot of grabbing a surprise place in the last 16.
While the Argentineans did their bit in beating the Super Eagles 3-2 in Porto Alegre to top the group on nine points, Iran's dream never looked like materialising in soggy Salvador, leaving Nigeria to advance on four points, ahead of Bosnia on three and Iran on one.
Susic opted to ditch a cautious 4-5-1 setup in favour of the attack-minded 4-4-2 that brought Bosnia 30 goals in qualifying, restoring Vedad Ibisevic up front alongside Dzeko in one of five changes for the Fonte Nova clash.
The result was a more controlled performance, with the Bosnians bossing most of the first half and going ahead when Dzeko came deep to collect a pass before advancing into space and firing a precise low shot in off the post from 23 metres.
Iran almost got level seconds after the restart when Masoud Shojaei struck the crossbar with a deft chip that saw the ball bounce onto the goal line and away, with Ghoochannejad unable to hook home the rebound.
In their previous two games Bosnia had been a pale shadow of the side whose attacking play had delighted fans in qualifying but with a more offensive shape they showed more zest and doubled their advantage before the hour mark.
Illustrating a scrappier second half, Dzeko picked up a loose ball out of the Iranian defence that allowed Tino Sven Susic, nephew of the Bosnia coach, to slide in Pjanic inside the area for a tidy finish.
Despite the roars of support the dogged defensive qualities that have won Iran plaudits in Brazil suddenly looked a little ragged and they struggled to reproduce the swift attacks that had worried twice champions Argentina in their last game.
As the rain poured down Ghoochannejhad provided a moment of cheer when he ensured Iran would avoid being the only team not to score in Brazil, scoring from close range.
Celebrations were short lived though as right back Vrsajevic's marauding run from deep saw him played in to thunder a third home off the far post just a minute later, ensuring Bosnia their first win over Iran in six attempts.
"The best team of the group did not qualify, Bosnia showed they have great players, great team with a lot of experience. Today they raised their levels and when that happened they gave us no chance," Iran coach Carlos Queiroz told media.
"My players went to the limit of our mental capabilities, fitness and I'm very proud, very, very proud."