MARTINSVILLE, Va. — Jimmie Johnson’s quest for his seventh career championship is alive and well. Johnson won Sunday’s race at Martinsville Speedway, locking himself into the NASCAR title race at Homestead-Miami Speedway next month. He’ll face three yet-to-be-determined drivers to decide the championship, which would be Johnson’s record-tying seventh if he won.

If that happened, the all-time championship leaders would be Richard Petty, Dale Earnhardt Sr. and Johnson. How persistence paid off for these former athletes But that’s still a long way from being decided. In the meantime, Johnson became a winner at Martinsville for the ninth time — tying Jeff Gordon, who was running perhaps his final race on Sunday.

“I’ve been trying to ignore this conversation about seven, but now I can’t," Johnson said in victory lane. "We’re locked in. I’m just honored to be in this position. … It’s crazy that we have a shot at seven now. … We’re going to enjoy this and savor this and try to get our ducks in a row for Homestead.”

Johnson’s victory was his fourth of the season and the 79th of his career. And it came on an unlikely day, thanks to some early troubles for the Hendrick Motorsports driver. Before the halfway point of the race, Johnson had contact with both Denny Hamlin and Aric Almirola in separate incidents. He needed extended time on pit road to repair the damage and was stuck in the low-20s for a time.

Later, Johnson briefly lost fuel pressure before a pit stop and dropped a couple positions. But after NASCAR sorted through a confusing scoring situation, Johnson restarted fourth and quickly moved past Denny Hamlin for the lead with roughly 100 laps remaining.

“Congrats to the 48, Jimmie, wow! That was impressive," said Gordon, who finished sixth while substituting for Dale Earnhardt Jr. in what is likely Gordon's final NASCAR race. "Everybody had (Johnson) written off. He had the damage on the left front. I hadn’t seen him in my mirror. He caught a break, but he had to go up there and race the 11 (Hamlin).”

Said Hamlin: “You try to do everything you can to hold them off. You got to be realistic too. That’s why I was frustrated with the 48 (Johnson), he’s got to be realistic and know he can’t hold me off for that amount of time. At the end of the race, I was realistic and let him (Johnson) go there. We’re going to root and gauge for every point we can.”

Martinsville Speedway has played a big part in the history of Hendrick Motorsports. It was the site of Rick Hendrick's first Cup Series victory as an owner in 1984 and also the site of family tragedy in 2004. A Hendrick Motorsports plane crashed near Martinsville's Blue Ridge Regional Airport killing all 10 on board, including Hendrick's brother, son and two nieces.

“The whole organization’s worked hard. It just feels good. This place is special," Hendrick said after Johnson's victory. "Twelve years ago we lost a lot of our family, friends. We dedicate this one to them.” Johnson echoed his longtime owner. "To win on this weekend at this racetrack with the tragedy we had here in ’04, just want to thank all the loved ones we lost," Johnson said.

Carl Edwards blew a tire in the middle of rare green-flag pit stops at the 0.526-mile track, which jumbled the running order and took awhile for NASCAR to sort out — nearly 30 laps of caution over 25 minutes. Eventually, NASCAR figured out the lineup and the race restarted with 10 cars on the lead lap with just over 100 laps to go. Joe Gibbs Racing drivers Hamlin and Kyle Busch held the front row with Hamlin taking the lead as the green flag dropped.

“I’m just confused on the scoring, why they couldn’t get the scoring right," Hamlin said. "There were a couple cars that stole a lap back from us and the other leaders. There’s gotta be a better way. There’s 20 cameras all over my racecar and it shows everybody going by me. That’s disappointing we can’t get that right.”