FORT WORTH, Texas — The timing was perfect for Kevin Harvick’s first Cup Series victory at Texas Motor Speedway. So was his winning pass.

Harvick went around the outside of Martin Truex Jr. for the lead on the 324th of 334 laps, then stayed in front the rest of the way Sunday to earn his championship shot in NASCAR’s finale.

Harvick got his first Cup win at the 11/2-mile high-banked track, where he had won five Xfinity Series races and once in a NASCAR Truck race.

“It’s been a long time coming,” said Harvick. “Great to check that one off.”

Truex led 107 laps and was still up front until his bobble on the backstretch allowed Harvick to take the lead. But Truex, with a significant points lead and wins in three of the eight playoff races, also clinched one of the four spots to race for the championship at Homestead-Miami Speedway in two weeks.

“A little disappointed to come up short, but to clinch a spot in Miami is unbelievable,” Truex said. “Definitely got the job done today, and came here and did what we needed to.”

Harvick and Kyle Busch also will be in the final four because of their wins during the third round of the playoffs. That leaves only one spot up for grabs at Phoenix next week. Brad Keselowski has a 19-point advantage over Denny Hamlin and a 22-point edge over Ryan Blaney for fourth place. Chase Elliott and seven-time champion Jimmie Johnson need to win next week to advance.

“I’d feel confident if we were locked in. These races, you don’t know what’s gonna happen,” Keselowski said.

Johnson was only three points out of the top four entering the race and has seven victories at the track. But he had to make an early stop because of a vibration issue.

“It was just a bad day that kept getting worse,” he said after finishing 27th, his second-worse finish in his 29 Texas races.

Harvick felt good about his car all day but spent several laps chasing down Truex. He eventually was able to execute on a cue he had taken from watching Kyle Larson driving really deep into Turn 1 earlier in the race.

“I knew I needed to do something different in order to get past Martin. I tried to just start driving it in there and we kept going faster and faster,” Harvick said. “I kept driving it in there, and one lap I got close enough to get the air off the back of his car. I actually got to the outside and was able to pass him on the outside.”