Hamlin led only 10 laps in the Cheez-It 355, but it came at the opportune time as he passed Brad Keselowski on Lap 81 and pulled away from the field following a seven-car crash that brought out the red flag with seven to go.
MORE: Hamlin wins wild showdown | Images from Watkins Glen
It’s the first career road-course victory for Hamlin, who showed his versatility after winning at Daytona in the opening race of the season.
Keselowski spun Martin Truex Jr. with four laps remaining, but it was Joey Logano who took advantage to finish second behind Hamlin. Logano has finished seventh or better in five of his last six starts at Watkins Glen.
Keselowski finished third, followed by road-course stud AJ Allmendinger and Tony Stewart.
Making his 800th career start and his third consecutive race in place of Dale Earnhardt Jr. (concussion), Jeff Gordon recovered after being involved in a dust-up with Austin Dillon early in the race to finish 14th.
Pole-sitter Carl Edwards led the first 25 laps but fell off the pace as he ran into multiple issues Sunday, including a pit-road penalty, trouble fueling his car on pit road and a wreck. Six-time champion Jimmie Johnson was also involved in a hard-hitting crash with Ricky Stenhouse Jr., Greg Biffle and Austin Dillon.
With Kevin Harvick finishing 32nd after a late-race wreck, Keselowski overtakes the top spot in the NASCAR points standings as the circuit heads to Bristol Motor Speedway after an off week with just four races before the Chase begins.