AP photo by Wilfredo Lee / Denny Hamlin crosses the finish line to win Sunday's NASCAR Cup Series race in Homestead, Fla.

HOMESTEAD, Fla. — Denny Hamlin found the magic at Homestead-Miami Speedway. Again.

Hamlin took the lead for the final time with 30 laps left Sunday and held off Chase Elliott for his record-tying third NASCAR Cup Series victory at the South Florida track.

Former drivers Greg Biffle and Tony Stewart are the other three-time winners at HMS. Hamlin joined the club after battling Elliott most of the night.

"This one was real special," said Hamlin, who raced to his third victory of the season and 40th overall on NASCAR's top tier. Among active drivers, he trails only seven-time Cup Series season champion Jimmie Johnson (83), who plans to retire at the end of this year; Kyle Busch (56), whose two Cup Series titles includes the 2019 crown; and 2014 season champion Kevin Harvick (51).

Hamlin, a 39-year-old Florida native, opened the season with a victory in the Daytona 500 — his third in the Great American Race, all in a five-year stretch — and won at Darlington Raceway last month in just the second Cup Series race after a two-month layoff due to the coronavirus outbreak. And when this long day-and-night at HMS was over, Hamlin — who wears the Michael Jordan "Jumpman" logo on his race suit — made no secret he's racing with some extra energy these days.

"I'm motivated. I'm motivated more than ever," Hamlin said.

At HMS, he led 137 of 267 laps on the 1 1/2-mile track in the Joe Gibbs Racing No. 11 Toyota, finishing 0.895 ahead of Hendrick Motorsports' Elliott.

"I just need to get through lap traffic better," Elliott said.

Team Penske's Ryan Blaney was third in a race delayed multiple times by lightning and rain, with Richard Childress Racing's Tyler Reddick fourth and Stewart-Haas Racing's Aric Almirola fifth.

"I just needed to execute a little bit better," Reddick said. "It was tough. We were just a little bit off there in the last two runs."

Fittingly, a very long day was the capper to a very long week for NASCAR — three Cup Series races in eight days, all of them bringing drivers into hot and steamy weather conditions that left many of them exhausted, all wrapped around the ongoing national outcry surrounding the battle for racial equality.

Bubba Wallace, the only black driver in the Cup Series, became the sport's most prominent activist this past week after he successfully called on NASCAR to ban Confederate flags at its events; the series quickly did just that to mostly rave reviews. So, while fans — 1,000 of them, mostly invited military members who could each bring a guest — were back at a NASCAR race for the first time since the coronavirus pandemic started, there were none of the banned flags in sight.

Most of those fans were gone when Hamlin drove under the checkered flag at 10:46 p.m.

The race was over. So was the day. Finally.

"I knew if I was just patient, ran the pace I wanted and the pace I was comfortable with, we were going to be hard to beat in the long run," Hamlin said.

some text
AP photo by Wilfredo Lee / Joe Gibbs Racing driver Denny Hamlin jumps from his car after winning Sunday's NASCAR Cup Series race at Homestead-Miami Speedway in South Florida.

Busch was sixth in another JGR Toyota, with Austin Dillon, Christopher Bell, William Byron, and Brad Keselowski rounding out the top 10.

Clint Bowyer was 11th, followed by Martin Truex Jr., Wallace, Matt DiBenedetto, Michael McDowell and 16th-place Johnson, who had the tunnel that leads to the track named in his honor but was unable to end the winless streak that stretches to 2017.

Hamlin won the first two stages and bucked a trend this season in which drivers who do that don't wind up with the win. Elliott swept the first two stages at Las Vegas Motor Speedway before finishing 26th, Bowyer did it before finishing 22nd at Darlington, Alex Bowman took the first two at Charlotte Motor Speedway but ended up 19th, and Elliott did it again at Bristol and finished 22nd.

The last driver to win the first two stages and ultimately win the race was Truex at Martinsville Speedway last Oct. 27. That is, until now.

"I'll take every win I can," Hamlin said. "Let's just keep piling them up."

The weather toyed with the race all day.

A slight shower that affected only the third and fourth turns of the track popped up the very instant drivers fired up their engines to get things going. That was followed by the day's first batch of lightning, and the delay caused the race to start 55 minutes later than planned.

Drivers got through three laps — not even five miles — when lightning was spotted near the track and a caution came out that turned into a red-flag stoppage that lasted for 2 hours, 8 minutes. And after about 25 more laps once things finally resumed, lightning struck again to prompt another interruption of nearly 39 minutes.

NASCAR was experiencing South Florida summer conditions for the first time, with past HMS races having been held in November at twilight.

"It was a little bit different," Blaney said. "Obviously, we raced later than we thought, but on the other side of that, the race that we're used to down here usually ends a little bit later, too. It was difficult getting in and out of the car, that part stinks, but safety is important."

Counting the prerace delay, that was 3 hours, 42 minutes of sitting around during weather-related stoppages on a day when most of the track was completely dry throughout. It was 8:15 p.m. when the green flag dropped again, and drivers — who had been through only 33 laps to that point — had 234 trips around the oval to go.

Dillon had a day he'll never forget, though his seventh-place finish wasn't even close to the most significant development. He and wife Whitney became parents early Sunday, announcing the birth of a boy named Ace.

"Hardest thing I've ever had to do was say goodbye to go race today," Dillon wrote in the Instagram post in which he announced the birth. "Hopefully we bring back a trophy for Ace on the first day we welcomed him into this world!"

Instead, the trophy went to Hamlin, who has now won this season with stands full of fans (Daytona), no fans (Darlington) and some fans (HMS). The 2010 season runner-up, he has four other top-five finishes in the Cup Series standings, including fourth place last year.

He's already halfway to the six wins he reached in 2019, and Sunday's victory was another milestone.

"It's a number that I've been looking at for quite a few years, and at one point I didn't know if I'd get there," Hamlin said of the 40-win mark. "I've adjusted my goals since then. I don't think we're at the top of our game with our team yet."