LOUDON, N.H. — Denny Hamlin claimed his first Monster Energy NASCAR Cup Series win of 2017 and the first win of the year for Joe Gibbs Racing Sunday with his victory in the Overton's 301 at New Hampshire Motor Speedway. It was Hamlin's third win at NHMS.

Kyle Larson closed on Hamlin in the closing laps but was unable to catch him. Martin Truex Jr. finished third, Matt Kenseth was fourth, and Kevin Harvick rounded out the top five.

Hamlin took his first lead of the race by getting off pit road first during a caution at the start of stage three and the second half of the race. Previous race dominators Truex and Kyle Busch waged a three-wide battle with Hamlin for the lead for several laps before Truex took the top spot.

Truex gave up the lead to pit with a flat right-front tire on lap 218 of the 301-lap race, but others followed suit, kicking off a cycle of green-flag pit stops. Busch inherited the lead with Truex pitted, but Busch was nabbed speeding on pit road when he made his stop. Truex reassumed the lead at the end of the cycle.

Kenseth, on newer tires than Truex, took the lead on lap 261, just before the yellow flag waved for the seventh and final time. Dale Earnhardt Jr. restarted with the lead after staying out, with Kenseth alongside in second with two new tires. Truex and Hamlin restarted in the second row, each with four new tires.

Kenseth, and later Hamlin, took the lead, but Truex dropped back several positions on the restart. Larson eventually got up to second and Truex to third, as Hamlin continued to lead late in the race.

After starting on the pole Truex led the entire first 75 laps of the race and claimed his 14th stage win of the season. He gave up the lead, though, to pit during the caution between stages, and as a result, restarted 24th due to varying pit strategies.

In addition to the traditional caution between the first two stages, the red flag was displayed for track repair, specifically for the patching of a four-inch by eight-inch hole in the track.

Most of the race field pitted when the yellow flag waved on lap 68 for a Cole Whitt blown engine. Truex and a few other front runners, including Kenseth, Larson and Jamie McMurray, stayed out. Busch was the first off pit road among drivers who pitted and restarted in the back of the top 10.

Truex, Kenseth, Larson and McMurray maintained their positions for the two green-flag laps that remained in the opening stage, but they pitted when the stage ended. Those who pitted during the lap 38 caution stayed out, and Busch and Ryan Blaney restarted on the front row.

Larson was outside the top 20, again, for the start of stage two as a result of his end-of-stage-one pit strategy. He had already raced from the back of the front, starting the race in the back and getting up to seventh by a lap 35 caution. He was up to fourth by lap 50.

Jimmie Johnson fell to the back at the start of the race when he was penalized for jumping the start. Unlike Larson, he had trouble getting up through the field. Partly through his early-race pit strategy, though, Johnson began the second stage in the fourth position.

By lap 100, Truex was back inside the top 10 and Larson inside the top 15.

Busch remained up front for the duration of the second stage, pulling away from the rest of the field to claim the stage two win, his fifth stage win of the season. Truex was back inside the top 10 shortly after a lap 92 restart. He finished the second stage just outside the top five in sixth.

Busch's Joe Gibbs Racing teammate Hamlin was second at the end of stage two, followed by Stewart-Haas Racing teammates Harvick and Kurt Busch. Johnson was fifth.

NOTES: Kyle Larson was fastest in Friday's opening practice and in qualifying on Friday, but his car failed post-qualifying inspection. As a result, he started in the back for the second race in a row, both times because of an inspection issue. ... Four Monster Energy NASCAR Cup Series regulars—Kyle Busch, Larson, Brad Keselowski and Ty Dillon—competed in the NASCAR Xfinity Series race at New Hampshire Motor Speedway on Saturday. Busch won and Keselowski led 102 of the 200-lap race. All four drivers finished in the top 10. ... NHMS track personnel reapplied a traction compound to the lower portion of the race track on Sunday morning. The compound originally was applied to the same area of the track prior to the race weekend that also includedNASCAR Whelen Modified Tour and Xfinity Series races. ... Another JGR driver, Denny Hamlin, started the Overton's 301 in a backup car after a practice crash. ... Kevin Harvick won the most recent Cup Series race at New Hampshire last fall. ... The Overton's 301 was Aric Almirola's first race after being sidelined for seven races because of a back injury sustained in a crash at Kansas Speedway in May.