Dale Earnhardt Jr. triumphed through a long afternoon of miscues and mayhem to win Sunday's Pocono 400 at Pocono Raceway and lock himself into the Chase for the Sprint Cup.

Earnhardt passed an overheating Brad Keselowski with five laps to go to win his second race of the season, followed by Kurt Busch's Stewart-Haas Racing Chevrolet, Denny Hamlin's Joe Gibbs Racing Toyota and rookie Kyle Larson in a Chip Ganassi-owned Chevy.

Keselowski dominated the race, leading 95 of 160 laps, but in closing stage of the race, picked up a piece of debris on his grille that was causing the engine to overheat. When Earnhardt passed him with five laps to go, Keselowski tried to pull up to the rear of Earnhardt's car to dislodge the debris but couldn't get close enough.

Earnhardt said he had to keep Keselowski well back in the final laps. "He knew I wasn't going to do that," Earnhardt said of allowing Keselowski to close on him. "Brad definitely had the better car. I'm owning up to that, but we won the race and we're definitely going to enjoy it."

"The car wasn't going to make it," Keselowski said. "It was already starting to blow up. It was all I could do. But Dale made a heck of a move to take advantage of it and sometimes that's just how racing goes."

With the victory, Earnhardt becomes the fourth two-time winner of the season, in this, his first multiple-victory season since 2004. It also made up somewhat for a race earlier this season at Las Vegas when Earnhardt was leading and ran out of gas on the last lap, handing what seemed to be a sure victory to Keselowski.

By his own admission, Earnhardt's Hendrick Motorsport Chevrolet wasn't as fast as Keselowski's Penske Racing Ford this time. But the third-generation driver was in the right place at the right time to score his first victory at the 2.5-mile, three-turn track and the 21st of his career in 519 NASCAR Sprint Cup Series starts.

"He had me beat, I couldn't get to him," Earnhardt said of Keselowski. "Just real hard to pass here. But I've lost some in some strange ways, so it feels good to win one like that."

It was a bizarre afternoon at Pocono, as a number of top cars suffered problems of one sort or another.

Hamlin started from the pole, but it was the third-qualifier Keselowski who went into the lead on the opening lap.

Once in clean air Keselowski dominated the first half of the race, leading the first 56 laps until he had to pit under green for regularly scheduled service. 

Following a caution for debris on Lap 73, Tony Stewart jumped into the lead on the restart, pulling his SHR teammates Kevin Harvick and Kurt Busch with him, as Keselowski fell to fourth.

On the next restart on Lap 84, it was Busch who briefly put his SHR Chevrolet out front over Stewart and Harvick. All told, Keselowski led 70 of the first 80 laps, but once he fell out of the lead, struggled to get back up front.

Hamlin took the lead on Lap 96, just after the three SHR drivers pitted along with Team Penske teammates Keselowski and Joey Logano. But Hamlin had to come in a couple of laps later, putting Earnhardt on the point for the first time all day.

The lead continued to shuffle while green-flag stops continued, with rookie Kyle Larson leading for the first time all season.

Finally, when all the stops had cycled through, Stewart has out front on Lap 113.

On Lap 118, the yellow waved for fluid on the track, with some drivers pitting and others opting to stay out. Stewart was too fast in four different sections on pit road, which cost him the lead and dropped him from contention.

Under caution, Keselowski was one of 12 drivers that stayed out and reassumed the lead over Earnhardt and Clint Bowyer.

The green came out on Lap 123, and six laps later, Keselowski pitted, surrendering the lead to Earnhardt, who led for three laps before pitting himself.

On Lap 135, Keselowski passed Earnhardt and Johnson to move into sixth place, with the five cars ahead of him all needing to pit again.

Then Danica Patrick bounced off the wall, bringing out a caution on Lap 138. Keselowski held the lead on the restart, but next Kasey Kahne crashed hard with the Roush Fenway Fords of Carl Edwards and Greg Biffle suffering damage as well. It appeared as though Kahne was driven up the exit of Turn 1 and into the wall by Kyle Busch.

The race restarted with 12 laps to go, and Keselowski again made a perfect restart to drive to the lead. But he got a piece of debris on his grille, which sent the temperature of his engine soaring.

Keselowski tried first to get on Danica Patrick's bumper to dislodge the debris, but she got loose and broke his momentum, which allowed Earnhardt to catch Keselowski and pass  him with five laps to go and that was it.

"When I talk about my team, I really mean it," Earnhardt said. "Them guys are a hell of a group. ... I don't have much to do tomorrow, so tonight's going to be a long one."