And on a cooling track, Hamlin's worn tires simply gave out.
As the sun set Sunday over Indianapolis Motor Speedway with Hamlin seven laps from one of the few victories that has eluded him, he went careening into the first-turn wall with a flat right-front tire, and Harvick beat Matt Kenseth off the final restart to win his second straight Brickyard.
"We had great tire wear today, so I was able to really push my car as hard as I could," Harvick said after his third 400 title. "I was able to push him a little harder that last run than earlier in the race, and when the sun went down, the track was cooling and speeds were going up in the turns."
The strategy worked out perfectly -- just like Stewart-Haas Racing's holiday weekend.
Not only did Harvick race to his 53rd victory to move within one of tying Lee Petty for 11th on NASCAR's career list, teammates Aric Almirola and Cole Custer, a rookie, finished third and fifth Sunday. Fellow Stewart-Haas driver Chase Briscoe won the Xfinity Series race Saturday or the road course.
Harvick tied Hamlin with a season-high fourth victory and leads in the points. The California driver has four straight top-10 finishes.
And for the third straight race, it looked as if it would be another one-two finish for Harvick and Hamlin.
But until the late, stunning twist, Hamlin looked as though he would take his first Brickyard.
"It's just, it's tough. I hate it for the FedEx team," the frustrated Hamlin said. "It was just kind of roulette if it (the tire) stays together or not, and mine didn't."
How dominant have Harrvick and Hamlin been recently?
After trading victories and runner-up finishes at Pocono last week and Sunday's result, they've combined for seven of 12 victories since the season restarted at Darlington in mid-May, and it's only the second time in seven races Hamlin and his No. 11 Joe Gibbs Racing entry hasn't finished in the top seven.
But as crew chief Rodney Childers plotted strategy and monitored tire wear, he sensed Hamlin was on borrowed time.
"We tried to play it a little safe and we had backed down ours down a little bit to save our tires," he said. "It just depends on how that situation plays out at the race and it just so happened we were out there a long time on tires, so backing down was the way to go."
Kenseth couldn't catch him.
"We were really fast," the Chip Ganassi Racing driver said. "I think if we were in front, would have been tough to beat.
One person was noticeably absent: seven-time Cup champion Jimmie Johnson in the No. 48 Hendrick Motorsports car. Johnson, who has tested positive for the coronavirus, watched the race from his Colorado home, as the series' longest active streak of consecutive and fifth-longest in series history ended at 663. Johnson was hoping to become the third driver to win five races on the 2.5-mile oval.
Instead, Justin Allgaier replaced him in the car and he didn't stick around long.
Allgaier was involved in a six-car pileup near the entrance to pit road that brought out a red flag on Lap 16 when one of Ryan Blaney's crew members was pinned between two cars. Track workers put Zachary Price on a stretcher, and he was transported to a nearby hospital, where he was treated and later released.
Two laps later, Allgaier's day was over.
"I didn't know if I got the gentleman on the No. 12 or not," Allgaier said. "Once the wreck started happening in front of us and we all got bottled up there, one car after another was getting run into. It's just a shame. I hate it for these guys."
Kurt Busch also had a rough day after making his 700th career start. After starting second, his hopes for winning one of the Cup's crown jewels faded with an early mistake during a pit stop. A plane flew over the track during prerace activities to celebrate the milestone, which broke a tie with Hall of Famer Buddy Baker for No. 16 on the series career list.
NASCAR's weather problems also continued, this time with the start delayed 55 minutes for lightning.
But once the race started, it was clean sailing for Harvick. He led for most of the first stage before giving way to William Byron, who chose not to pit with nine laps to go, and then won the second stage before earning the big prize.
"We weren't going to get by him (Hamlin) unless he made a huge mistake, and obviously his tire was wearing out," Harvick said. "His car was a little better than me on the long run. We were better on the restarts, so we would have needed a caution -- we couldn't have beaten him on a green."
The Associated Press contributed to this report.