Denny Hamlin prevailed in a four-lap dash to the checkered flag Sunday in the wreck-filled Sprint Cup race at newly paved Watkins Glen International.
It's the first road course win of Hamlin's Cup career and 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's No. 11 Joe Gibbs Racing Toyota coasted to the victory.
Joey Logano finished second, followed by Penske teammate Keselowski, AJ Allmendinger, and Stewart.
Kyle Busch, Truex, Jamie McMurray, Trevor Bayne and Matt Kenseth rounded out the top 10. Polesitter Carl Edwards, who led the first 25 laps, finished 15th.
Stewart, who is retiring after the season, will finish his stellar Cup 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 visited Watkins Glen on Friday and is recovering from a concussion. He will miss at least two more races.
The race, which featured seven cautions and two red flag stoppages, was shaping up as another duel between Brad Keselowski and Kyle Busch in the closing laps. But a rash of late cautions shuffled Busch back.
Keselowski restarted with the lead with 25 laps to go, and Busch stalked him in second as the leaders began turning the fastest laps of the race with the end in sight.
The sixth caution flew on lap 78 for a blown engine in Alex Kennedy's No. 55 Chevrolet and erased a 5-second lead the two leaders had built over Hamlin, Truex and Logano.
Keselowski lost the lead on the restart when both he and Busch overdrove the first turn, a 90-degree downhill right-hander, and Hamlin sneaked past to take the lead before another caution flew. Busch dropped to fifth, but Keselowski only dropped a spot.
Hamlin held the lead on the next restart, and Busch made it three-wide entering the first turn as he tried to regain the lost spots. Seconds later, the race's second red flag waved when a crash took out Kevin Harvick, Chris Buescher, and David Ragan with only six laps left in the 90-lap race, setting up the frantic finish.
"Let them make the mistakes," Keselowski said before the final restart.