Iran had a goal disallowed after a VAR review, while Mehdi Taremi was among those to miss chances for Carlos Queiroz's side.
Iran was later denied an equaliser by the video assistant referee as the got a word in his ear that "goal-scorer" Saeid Ezatolahi was in fact offside.
"The match the other day was not easy but I think the team has shown we know what we are doing and we trust what we are doing".
Iran are top of Group B after beating Morocco 1-0 on Friday. Do not cut, copy or lift any content from this website without our consent.
Brazil, Argentina and Germany all failed to win their opening games, while France, England and Portugal - in their second game - all labored to secure three points against lower-ranked opposition.
Some great vision from Iniesta, and a slice of luck, however broke Iranian hearts when Costa spun and latched on to the ball before seeing his shot rebound off Ramin Rezaeian and into the net.
"We are very happy with three points".
Ronaldo header lifts Portugal over Morocco
A frustrated Fernando Santos has hit out at suggestions that Portugal rely too heavily on talisman Cristiano Ronaldo . And he says the Danes are better team than world No.7 France, who pipped Australia 2-1 in the tournament opener.
The Manchester United goalkeeper was at fault for the second goal of Cristiano Ronaldo's hat-trick in the thrilling 3-3 draw with Portugal in Sochi in their Group B opener.
Iran thought they had taken the lead on 53 minutes from a set-piece, but the ferocious Karim Ansarifard half-volley only struck the side-netting.
They said his style of play was not right for the national team. When asked about what achievement he wants to make, he said that athletes always want to achieve the highest possible title, and they are now hoping to win the World Cup here.
With the unlucky 1-0 loss to Spain, Iran are now winless against European opposition at the World Cup.
Boasting Asia's meanest defense, Queiroz's well-drilled Iran were typically grudging, but they will again rue the lack of a clinical touch after a number of chances went begging.
Queiroz was nonetheless proud of his players, and said they would head into the Portugal decider with confidence.
After Wednesday, Team Melli will finish their group stage campaign on June 25 against Portugal, which will pose a different but equally hard obstacle.
While that may not differ too much from the scenario in many group stage matches pairing the big beasts of the game against those nations who occupy lower rungs of the Federation Internationale de Football Association rankings, the X-factor in Kazan could be Carlos Queiroz.