Amir Ghalenoei's side completed their Group G campaign on Friday with a 1-1 draw against Egypt, leaving them waiting to discover whether three points would be enough to earn a spot in the round of 32.
Iran had already endured one major setback when a stoppage-time winner against Egypt was ruled out for offside.
That left them needing other results in group-stage matches to go their way, and for a few minutes on Saturday (Sunday AEST) it looked as if Iran were going to squeeze through when Algeria struck in stoppage time to lead Austria 3-2.
However, the Austrians equalised with almost the final kick of the game, salvaging a 3-3 draw that sent both teams through and denied Iran a place in the knockouts in their seventh World Cup appearance.
Iran leave unbeaten after draws with Belgium, New Zealand and Egypt in a challenging campaign due to issues off the pitch.
Uncertainty over visas and Iran's conflict with the US meant the team had to commute from their tournament base in co-hosting Mexico for their three group games in the United States.
US authorities required them to enter within 24 hours of a match and leave the same day, though the restrictions were eased slightly for their final game in Seattle, where they were allowed to arrive two days ahead of the game.
President Donald Trump had said in March that Iran were welcome to participate in the World Cup but he did not believe it was appropriate for them to be in the United States "for their own life and safety".
After the draw with Egypt, captain Mehdi Taremi described the situation as a logistical "disaster" and questioned whether his team were truly welcome at the tournament.
"Who wants to help us?" Taremi told reporters. "If they want us to be out - OK, let's be out. But that's not fair."
Key members of the delegation had been unable to join the squad in the US, and Iran coach Ghalenoei said his team were being "oppressed".
Ultimately, Iran's campaign came down to moments.
Had Taremi scored a first-half penalty against Egypt, or had his header hit the net instead of the crossbar later on, Iran might have been looking forward to a knockout match for the first time.
In a statement as they headed home, the Iranian federation (FFIRI) thanked the media for covering their situation, and reiterated their displeasure at the team's treatment.
"Thank you for your professionalism, your support and for covering not only our team's sporting journey but also the unfair and unsportsmanlike treatment our delegation experienced during our stay," the statement said.
"Your commitment to reporting the facts with accuracy and integrity has meant a great deal to us.
"We would also like to extend our heartfelt appreciation to the wonderful people of Mexico, especially the beautiful city of Tijuana and its kind, warm-hearted residents. You welcomed us with generosity and genuine hospitality, making us feel at home. Leaving Tijuana is truly difficult for all of us."