Updated

Talladega, AL (SportsNetwork.com) - Denny Hamlin is virtually assured of making this year's Chase for Sprint Cup championship after winning Sunday's Aaron's 499 at Talladega Superspeedway.

Hamlin grabbed the lead from Kevin Harvick after the final restart with just two laps to go and then held off a challenge by Greg Biffle for the top spot before the race ended under caution.

A four-car accident triggered by Carl Edwards in the closing laps set up the two-lap sprint around this 2.66-mile superspeedway to the finish. Hamlin and Harvick had exchanged the lead several times within the final 20 laps before Hamlin pulled ahead for good following the last restart.

Biffle was running second to Hamlin when they crossed the line to complete the penultimate lap. Rookie Justin Allgaier spun out and damaged his car on the final lap. Part of Allgaier's bumper was on the frontstretch, forcing NASCAR officials to display the caution flag for debris. Biffle was battling Hamlin for the lead on the backstretch when the caution came.

"I was backing up from [Hamlin] right when the caution flag came out," Biffle said. "I had a chance at him going into [turn] 1 there. Clint [Bowyer] gave me a huge push. I saw the smoke in the mirror, and I thought, 'Should I go now?' I was thinking the caution was going to come out. There was silence on the radio, so I thought that maybe the track is okay and we're going to race back.

"I was backing up on the backstretch to get a run at him. And then the caution came out. I was like, 'Dang it.' I could have been beside him for sure and taken that chance, but I just didn't know there was a big bumper laying there on the track."

Hamlin was just ahead of Biffle when NASCAR froze the field at the time the caution flag was displayed. Hamlin won a Sprint Cup Series points-paying race at a restrictor-plate track (Talladega and Daytona) for the first time in his career.

Hamlin had struggled on restrictor-plate tracks prior to this season. He began the 2014 season by winning the pre-season, non-points race at Daytona and then scored the victory in a qualifying race (Budweiser Duel) for the Daytona 500. He finished second to Dale Earnhardt Jr. in the Feb. 23 Daytona 500.

"We've come a long way," said Hamlin, whose first Talladega win came in his 17th start here. "We couldn't finish well in superspeedway races for the longest time. Now it seems like when we go there we got the knowledge and the car that can win. So it feels good to come to these types of racetracks and know you can win."

Hamlin scored his 24th win in his 300th career Sprint Cup start. He joined Ned Jarrett, Rusty Wallace, Kasey Kahne and Kyle Busch as those drivers who won on their 300th starts. Hamlin's most recent victory in a points-paying race came last November in the season-finale at Homestead, Fla.

"It feels good to be back in victory lane, in a points-paying event, anyway," he said. "We were able to play our cards right and make the right strategy. Just proud of our day today."

Hamlin failed to make the Chase for the first time in his career last year when he missed four races early in the season due to a back injury. In the 2013 spring race at Talladega, Hamlin ran just the first 23 laps before Vickers relieved him in the No. 11 Joe Gibbs Racing Toyota.

Biffle ended up finishing a season-best second after leading the most laps with 58. Hamlin was in front for a total of 12 laps.

Michael Waltrip Racing drivers Clint Bowyer and Brian Vickers finished third and fourth, respectively, while A.J. Allmendinger took the fifth spot.

Paul Menard, Harvick, Kahne, rookie Kyle Larson and Ricky Stenhouse Jr. completed the top-10.

This race featured eight cautions, including two for big crashes. The first major accident involved 14 cars and was started by Brad Keselowski when he spun around on lap 137. Keselowski also spun out early in the race when Danica Patrick bumped into him. He had just taken the lead from Patrick, who had run in front for a total of six laps.

"Every wreck is a byproduct of Talladega," Keselowski said. "That's just the track we're on but racing hard. Everybody wants to lead laps, and everybody wants to run up front. Certainly, I wanted to get my laps back and have a shot to win at the end. The only way I was gonna do that was by being really aggressive at the front half of the field."

Jeff Gordon and Matt Kenseth, who are 1-2 in points right now, were among those involved in the lap 137 crash.

"Brad made a pretty bold move early, a mind-boggling move I guess you could say, in going in front of Danica and then spun out in front of the field and got away with it," Kenseth said. "I thought he was a bunch of laps down, but maybe he was just trying to get back on the lead lap. He just spun out in front of all of us and tore up a bunch of good race cars. It's really unfortunate."

Gordon, who has yet to win a race this season, holds a three-point lead over Kenseth and a four-point advantage over Kyle Busch, who finished 12th.

"It's unfortunate what happened to [Keselowski] earlier, but it was much more unfortunate what happened to us there [on lap 137]," Gordon said.

The second big wreck, involving eight cars, took place on lap 175 when Jimmie Johnson got bumped into by Stenhouse. Joey Logano had led 25 laps before he was caught up in the crash.

"The 48 [Johnson] just started spinning out in front of me," Logano said. "That's Talladega. You come into this race almost expecting something like that to happen. It's unfortunate. We had a really fast car."