On the final green-flag stop with 35 laps left, Carpenter beat pole-sitter and season points leader Power off pit road. Team Penske driver Power made things worse when he was penalized for speeding out of the pits.
"That's four drive-thru penalties in five races," Power lamented.
Power was sixth, and Carpenter had a lead of about 18 seconds over Juan Pablo Montoya, when Takuma Sato's engine blew and his car caught fire with 10 laps left.
While the top four cars stayed out during that caution, Power went in for fresh tires. That gave him the chance to make up some ground, and he made a big charge after the final restart to finish second, only a half-second back.
With another lap, the outcome might have been different.
"I don't know. Ed was awfully strong," Power said. "He's an awesome driver and it would have been a good battle at the end. ... It was a lot of fun."
Carpenter's third career victory, all on ovals, came after leading 90 of 248 laps.
After winning at Kentucky for Sarah Fisher Racing in 2011, he started his own team the next year and won the season finale at California. Carpenter was on the pole at Indy the last two seasons, and this year is leaving the road and street courses to Mike Conway.
Conway won at Long Beach the second race this season and was in the cockpit for both races at Detroit last weekend.