Logano took the lead from Patrick Sheltra with a lap to go, but Allgaier -- set to drive a NASCAR Nationwide Series car next year for Penske Racing -- surged ahead on the outside on the 94th and final circuit around the 2.66-mile track.
"Penske gave me an engine for this race. This is the first time I've ever been in a Dodge," said the 22-year-old Allgaier, from Riverton, Ill. "We fought hard today."
Allgaier has won consecutive races, giving him a series-high five victories this season. He won last week on the road course at New Jersey Motorsports Park.
Logano led 15 laps.
"I don't know. I did everything I could do. I just got beat," Logano said. "He just schooled me. I learned a lot and I will do things different next time."
Bobby Gerhart was third, followed by Jeremy Clements, Sheltra and Frank Kimmel. Points leader Scott Speed finished 23rd in the race was slowed by seven caution periods that consumed 51 laps.
Forlán Returns To Recover In Madrid
Logano ending Hall of Fame Racing experiment