The result gave Japan a taste of revenge for their defeat to Iran in the 2002 final, although they had to fight hard for the win. Afshin put Iran in front when he picked up a ball whipped in from the right and lashed it past goalkeeper Yuki Saneto from six yards.
But Japan, who despite being an Asian football powerhouse have never won an Asiad title, always looked like getting back in it. They came into the game boosted by the tournament's joint top scorer Nagai being passed fit, but it was Kota Mizunuma who drew them level.
The 20-year-old stabbed the ball through the legs of Iran goalkeeper and captain Osgouei Rahmati and past two defenders on the line after a goalmouth scramble. In an open game, the dangerous Ashfin had the chance to put Iran in front again just before the break but his 30 yard drive was gathered by Saneto.
Both sides came out for the second-half fired up and Iran were unfortunate not to get a second on 53 minutes when Karim Ansari's long-range strike was parried by the goalkeeper. Afshin followed up on the rebound only to miss burying it under pressure from a defender.
It was Nagai who broke the deadlock with a goal that Wayne Rooney would have been proud of. He picked the ball up outside the penalty area and dribbled past three defenders before unleashing a right-foot drive into the bottom left-hand corner.
It sparked Iran into a frantic search for goals and they were unlucky not to be level when Ansari put the ball into the net 16 minutes from time only to be judged offside.
The Iranians were throwing everything they had at the Japanese goal and Hamidreza Akiasgaridehaghi hit the post and they had a penalty appeal turned down, but Japan held on for a narrow victory.