Iran's hopes of qualifying for the World Cup last 16 ended as they lost to already-eliminated Bosnia-Hercegovina.
Carlos Queiroz's Iran side could have progressed to the second round with a win but their hopes were dented when Edin Dzeko gave the Bosnians a deserved lead with a crisp shot from 25 yards.
Roma's Miralem Pjanic slid home a second after the break.
Reza Ghoochannejad pulled one back but Avdija Vrsajevic sealed it to give Bosnia their first World Cup win.
Bosnia's first ever victory in a major tournament at least gives the European side something to show for their efforts in Brazil.
"Bosnia have their maiden World Cup win but they will be kicking themselves that they are not going further in this tournament. They took their chances and proved they were by far the better team. They could have gone up another gear. The right side won."
Safet Susic's side were knocked out before Wednesday's match after narrow defeats by Argentina and Nigeria in their opening two games but had created enough chances to have taken something from both games.
For Manchester City forward Dzeko, his well-taken goal will feel like scant consolation after he had an effort wrongly ruled out against the Nigerians when the score was 0-0, before missing a number of opportunities to get his side back in the game.
His 23rd-minute strike was little more than the Bosnians deserved after a positive start in which the City man had twice forced saves from Iran keeper Alireza Haghighi.
With the Iranians needing a win - and a Nigeria defeat - to progress, they immediately went on the attack and Masoud Shojaei saw his shot come back off the crossbar less than a minute after Bosnia had scored.
It would have been their first goal in a World Cup finals since a 1-1 draw with Angola in 2006, but the half ended with Susic's side looking more likely to be the next team on the scoresheet.
They made it 2-0 with just under an hour gone when Iran needlessly conceded possession 40 yards from goal and Tino Susic moved forward before sliding through the marginally offside Pjanic who finished coolly into the corner.
Iran pulled themselves back into it when Ghoochannejhad tapped home at the back post after Bosnia failed to clear a corner but any hopes of a comeback were short-lived. Almost from the restart Sejad Salihovic played full-back Vrsajevic through on goal and he showed good composure to score his first international goal.
Bosnia could have added to their tally but for some wasteful passing as Iran continued to push for an unlikely route back into the match.
Iran, under the management of former Manchester United coach Queiroz for the final time, have now gone out at the group stage in all four of their World Cup campaigns.