Andretti, who started 17th, passed former teammate and defending Iowa race winner Tony Kanaan with 18 laps remaining and then held him off at the finish, coming in first by 0.8 seconds.
It was Andretti's second career IndyCar win but his first since August 2006.
Dario Franchitti led 172 of 250 laps but faded in the final 70.
Scott Dixon bounced back from his 23rd starting position to finish third while rookie J.R. Hildebrand took the fourth spot.
Franchitti, who now holds a 20-point lead over Will Power, ended up in fifth place.
Power was involved in an early crash and ended up 21st.