TALLADEGA, Ala. — Brad Keselowski was in trouble when he arrived at Talladega Superspeedway ranked 10th in the NASCAR Cup Series playoff standings. He knew he’d need a big finish to keep his championship chances intact.

He delivered.

Keselowski earned an automatic berth into the third round of the playoffs with a victory Sunday at Talladega Superspeedway, where he considered himself lucky to finish after a sloppy day for NASCAR.

“I survived,” Keselowski said. “I feel like only eight cars finished the race. It was one of those crazy days … a lot of attrition.”

There were just 14 cars running at the conclusion, and only four were playoff drivers. The race was red-flagged three times for nearly 35 minutes.

By avoiding the carnage, Keselowski won for the fifth time at Talladega and gave Ford a season sweep of the four restrictor-plate races. Most important, though, is that he knows he’s still in the hunt for his second Cup title.

Talladega was the perfect place for Keselowski to take the stress off his Team Penske team. He’d done it at the Alabama track before.

When the elimination format was rolled out in 2014, Keselowski had to win at Talladega to advance. The race this year was moved to the middle event of the second round, so eliminations weren’t at stake, but Keselowski no longer needs to worry about advancing.

He was the leader when the race resumed with three laps left but was passed by Ryan Newman, who stayed out front until the final lap. Then Keselowski made his move around Newman on the high side of the track, and he used a crossover move to hold off Newman and Penske teammate Joey Logano.

It was the 24th career Cup win for Keselowski, and came in his 300th start. His first win was at Talladega in 2009.

Dale Earnhardt Jr. finished seventh in his final race at Talladega, where he and his father combined to win 16 Cup races. Alabama declared Sunday “Dale Earnhardt Jr. Day.”

Newman finished second in a Chevrolet and was followed by Trevor Bayne, Logano and Aric Almirola – all non-playoff drivers.

“Brad and I work really well together on these speedways,” Logano said. “I was able to push him up to the lead and I thought, ‘Alright, now I got you to the lead. It’s my turn to get up there and try to win this thing.’ Our never-quit-attitude got us a top-five out of a day that looked like we may not even finish. I’m proud of that.”

Denny Hamlin finished sixth, the best of the Toyota drivers. But the manufacturer’s winning streak came to an end after Martin Truex Jr. and Kyle Busch gave Toyota wins in the first four playoff races.

Of the top 10 finishers, only Keselowski and Hamlin were playoff drivers.

The rest of the 12-driver playoff field had a rough afternoon. Six playoff drivers were involved in a crash with 17 laps remaining, and three others were in later crashes.