Jeff Gordon earned an automatic berth in NASCAR's championship race -- where he'll try to win a fifth title in his final season -- with a victory Sunday at Martinsville Speedway.

He has Matt Kenseth to thank for his spot in the final four of the Chase for the Sprint Cup championship.

More from FoxSports

Kenseth intentionally wrecked Joey Logano -- payback from an incident three races ago -- to take the race leader out with 47 laps remaining. Logano had the dominant car, and Kenseth, who was in an earlier wreck with Brad Keselowski, came back on the track 10 laps down and drove Logano into the wall.

Logano had led 207 of the 500 laps and was furious. His father, Tom, had to be pushed into the team hauler by the crew chief as the crowd cheered wildly in support of Kenseth.

Kenseth downplayed the incident, deadpanning it was a result of his earlier incident with Keselowski, who had led 143 laps as the two Team Penske teammates were the class of the field. Instead of celebrating a win and a spot in the Nov. 22 finale at Homestead-Miami Speedway, Logano is last in the eight-driver field and Keselowski is sixth.

Gordon, though, is in after his ninth career victory at Martinsville.

"We're going to Homestead!" he screamed.

The four-time NASCAR champion won for the first time this season and first time in 39 races. It was his 93rd career victory and put him in position to ride into retirement with the long coveted fifth title.

One of the greatest drivers in NASCAR history, he hasn't won a title since his 2001 championship. He celebrated the win by jumping around the frontstretch like a little boy on Christmas morning, then he jumped into the arms of his exuberant Hendrick Motorsports crew.

As he stood in Victory Lane, his two young children racing in for hugs, he couldn't contain his glee.

"It was a joke, I'm coming back next year!" he joked. "This is the sweetest, most amazing feeling."

He still had to earn the win after Logano was knocked from the race. Gordon had to chase down AJ Allmendinger and Denny Hamlin on a restart, then hold off Jamie McMurray on a restart with two laps remaining.

There are two races remaining for the rest of the final four to be set, and Logano has a lot of work to do to make it back to the championship for the second year.

He was racing for his fourth consecutive victory, but there was a looming suspicion that Kenseth would get in the way.

Kenseth had been leading in the closing laps three weeks ago at Kansas Speedway when Logano spun him out of the way for the win. Kenseth has been furious since, and was eliminated last week from the Chase.

Logano felt Kenseth's move was dirty.

"I think what happened at Kansas is a completely different deal. We were racing for the win and he blocks you a few times and then we raced hard and he blocked me the last time and we spun out," Logano said. "Here it was just a complete coward move, especially for a championship race car driver and race team. Just a complete coward. I don't have anything else to say. It's a chicken-you-know-what move to completely take out the leader when your race is over."

The two drivers have not talked since Kansas, and even though they were in the care center together after the accident, there was no conversation.

"They won't let me get to him," Logano said of NASCAR.

Kenseth tried hard to dismiss Sunday's accident as a byproduct of earlier contact with Keselowski -- a wreck that sent both Kenseth and Keselowski to the garage. But he was summoned to the NASCAR hauler after the race for a meeting that his crew chief and car owner Joe Gibbs attended.

Kenseth eventually revealed why the wreck happened at Martinsville, the first of three races to set the championship field.

"He's got a couple races left, he's got the best car, he might get a couple of wins here and still have a shot at it," Kenseth said. He also indicated that payback had to be done.

"You never like to be in these situations. They really stink, to be honest with you, but sometimes you get put in these spots and you've got to try to keep respect in the garage area," Kenseth said.