Deco scored with a shot from outside the area in the 63rd minute and Cristiano Ronaldo converted from the penalty spot in the 80th.
Portugal now has six points and is assured of a place in the next round. The European team beat Angola 1-0 in its opening match.
Iran remained winless, having lost its opener to Mexico 3-1, and has been eliminated.
Portugal last reached the second phase of a World Cup tournament in 1966, when Eusebio led it to a third-place finish.
However, as against Angola, the Portuguese failed to find their usual sparkle and allowed their opponents back into the match after a bright start.
--- Lineups: Portugal: Ricardo Pereira, Miguel, Nuno Valente, Ricardo Carvalho, Fernando Meira, Maniche (Petit, 67th), Francisco Costinha, Deco (Tiago, 80th), Luis Figo (Simao Sabrosa, 88th), Cristiano Ronaldo, Pauleta.
Iran: Ebrahim Mirzapour, Yahya Golmohammadi (Sohrab Bakhtiarizadeh, 88th), Rahman Rezaei, Mohammad Nosrati, Hossein Kaabi, Anderanik Teymourian, Javad Nekounam, Mehrzad Madanchi (Rasoul Khatibi, 66th), Mehdi Mahdavikia, Vahid Hashemian, Ali Karimi (Ferydoon Zandi, 65th).