Spain produced some magnificent football which boes well for their tournament overall, but in Ronaldo, Portugal have a player capable of anything.
But Ronaldo stole the show with his third and most decisive goal of the match.
While Spain bossed possession, Portugal always looked a threat on the break, although young PSG attacker Gonçalo Guedes failed to make the most of a couple of promising attacks.
The goal marked the second-fastest goal in Portugal's World Cup history, falling only behind Jose Augusto's strike against Hungary at the 1966 edition in England.
"Spain striker Diego Costa produced an explosive performance and pledged to "keep working and keep on shutting people up" after his two goals answered critics who believe he does not fit into the team's style of play".
Portugal has been fending off distractions since star Cristiano Ronaldo hinted at an upcoming announcement about his future.
"I've been near a ball for 30 years", Hierro said while dismissing his lack of coaching experience. He also expressed his hopes that Ronaldo would still be around and scoring goals in Qatar in four years' time. He then calmly sent his shot to the right corner as De Gea went the other way.
In the second half, Costa equalised again. Three minutes later Spain took lead when Nacho's thunderbolt flew in off the post and the 2010 champions looked set to close the game out.
The World Cup victory was Iran's first since defeating the United States in 1998.