Jimmie Johnson grabbed a two-point lead over Brad Keselowski in the Chase for the Sprint Cup championship by winning Sunday's Tums Fast Relief 500 at Martinsville Speedway.

Johnson, the pole sitter, grabbed the lead from Keselowski with 14 laps remaining. An accident involving Carl Edwards and Dale Earnhardt Jr., who made his return after sitting out the previous two races due to a concussion, set up a five-lap shootout to the finish.

After the restart, Kyle Busch challenged Johnson for the lead, but Johnson managed to hold off Busch at the finish line by 0.5 seconds. He claimed his fourth win of the season. It was also his record-extending 21st Chase race victory but his first since Oct. 9, 2011 at Kansas.

"I'm ecstatic about the win today, and I'm ecstatic about the points lead," said Johnson, who earned his 59th career Sprint Cup victory, including his seventh at Martinsville.

Johnson's win allowed him to collect a total of five bonus points, including two for leading a race-high 193 laps.

The five-time Sprint Cup champion held the lead late in the race, but during a caution for Kevin Harvick's expired engine with less than 25 laps to go, he pitted from the top position to take two new left-side tires. Keselowski elected to stay out on the track and took over the lead. Johnson ran third for the restart with 19 laps left but quickly chased down Keselowski before making his winning pass.

"We had a great race car," Johnson said. "I think we also learned our lesson from the past here about not pitting late, and that really came into play, and we made the right decision there."

Keselowski had to patiently make his way through the field for most of the race after starting 32nd. With older tires, Keselowski faded in the closing laps to finish sixth. He came to Martinsville with a seven-point lead over Johnson.

Just three races remain -- Texas (Nov. 4), Phoenix (Nov. 11) and Homestead (Nov. 18).

"I know this championship is going to come down to Homestead, and you just got to be in a position where you have a shot at it, and we're doing the things that it's going to take," Keselowski said. "We'll keep fighting a good fight."

While Johnson and Keselowski are separated by two markers, Denny Hamlin took a big hit in points with a 33rd-place finish. Hamlin, who won Saturday's Camping World Truck Series race at Martinsville, was penalized for speeding on pit road twice during the first half of the Sprint Cup event. He then suffered an electrical issue that put him behind the wall for more than 30 laps. Hamlin dropped from third to fifth in the Chase rankings, as he trails Johnson by 49 points.

"When these things happen, you just got to suck it up and move on," a disappointed Hamlin said. "There's nothing I can do about it. One of these days it's going to be our time. It's just not going to be right now."

Kasey Kahne finished third, while Aric Almirola and Clint Bowyer rounded out the top-five. Bowyer moved up to third in points (-26).

Jeff Gordon finished seventh, followed Brian Vickers, Bobby Labonte and Greg Biffle. Earnhardt Jr. wound up finishing 21st.

"I was just really (ticked) off about how we finished that race," Earnhardt Jr. said about his incident with Edwards. "That was really ridiculous. I mean, you've got to use a little common sense, and that was not a good move."

Kahne is now 29 points out of the lead, while Gordon trails by 54.

Johnson's win allowed Chevrolet to clinch its 10th consecutive and 36th overall manufacturers' championship in NASCAR's premier series.