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

“It’s great. Definitely a team effort,” Hamlin said. “This is a — I put us behind on Friday with the backup car getting in a wreck, but this — I really wish we would race that car that was in the hauler, but this one, they did a great job getting it as close as they could working on the balance, getting it good yesterday and team effort. This is a total team effort all around.”

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.

“They’ve [Larson and the No. 42 team] just been so fast this year and we, honestly, haven’t been able to keep up, and so for us to be able to get the lead there, stretch it out, I knew it was going to be important for me to stretch out the lead as far as I could,” Hamlin said. “That way I could pace myself at the end of the race and it was just enough.”

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 for speeding on pit road when he made his stop. Truex reclaimed 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-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.

“It’s a little frustrating what we have had to go through the last couple of weeks, but it’s pretty awesome to be able to run as fast as we have and finish second the last two weeks from dead last,” Larson said.

“I’m proud of our team, proud of everybody at our race shop. I can’t thank my sponsors Target, Credit One Bank, and all of our other supporters enough for what they do for our team. It’s been a lot of fun these last couple of weeks to be as fast as we have been, so keep working hard at it and maybe we can get some more wins.”

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.

“I guess I just got it wrong at the start,” Johnson said. “I went off the flag and forgot that the pole-sitter has to be the first one to the stripe, so I’ll take the responsibility on that one. And then we had an OK finish. We had decent short run speed. We would just fall off too hard. I really thought we were going to be in a position for a top five, but we ended up 10th.”

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 victory 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.

Hamlin, Busch’s Joe Gibbs Racing teammate, 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 racetrack on Sunday morning. The compound originally was applied to the same area of the track before the race weekend that also included NASCAR 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. … Matt Kenseth won last year’s race at New Hampshire, his most recent win.