Updated

Denny Hamlin prevailed in a four-lap dash to the checkered flag to win a wreck-fest at newly paved Watkins Glen International on Sunday.

It's the first road course win of Hamlin's career as he survived a race that had eight cautions for 24 laps and two red flags for 30 minutes.

On the final lap, Hamlin, who was beaten on the road course at Sonoma in June by Tony Stewart in a bang on the last turn, held a slim lead over Martin Truex Jr. and Brad Keselowski as the three ran nose-to-tail entering the final turns of the 90-lap race. Keselowski spun Truex in the turn and Hamlin coasted to the victory.

Joey Logano finished second, followed by Keselowski, AJ Allmendinger and Stewart. Stewart, who is retiring after the season, will finish his stellar career with eight road wins, one fewer than the record nine of Jeff Gordon.

Gordon, who retired after last season, drove the No. 88 Chevy for Hendrick Motorsports in relief of Dale Earnhardt Jr. for the third straight race and finished 14th in his 800th career start. Earnhardt, who visited Watkins Glen on Friday, is recovering from a concussion and will miss at least two more races.