FORT WORTH, Texas (AP) The timing was perfect for Kevin Harvick's first NASCAR Cup Series victory at Texas. So was his winning pass.

Harvick went around the outside of Martin Truex Jr. for the lead with 10 laps to go, then stayed in front the rest of the way Sunday to earn his championship shot in NASCAR's season finale.

"It's been a long time coming," said Harvick, who had won five Xfinity races and a NASCAR Truck race at Texas in the past. "Great to check that one off."

Truex led 107 of 334 laps and was still up front until his bobble on the backstretch that allowed Harvick to take the lead. But Truex, with a significant points lead and wins in three of the eight playoff races, also locked into one of the four spots to race for the championship at Homestead 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."

Kyle Busch had already clinched a championship spot with his win at Martinsville a week ago to start the third round of the playoffs. That leaves only one spot up for grabs among the five remaining playoff contenders next week at Phoenix.

After doing a long burnout along the frontstretch in the No. 4 Ford for Stewart-Haas Racing, Harvick went to Victory Lane, where the Texas celebration was missing the traditional firing of six-shooters by the winner.

TMS officials bypassed the use of the pistols after a man armed with an assault rifle opened fire earlier Sunday inside a church in the small community of Sutherland Springs, about 300 miles south of the track near San Antonio. The man killed 26 people and wounded about 20 in what Texas Gov. Greg Abbott said was the deadliest mass shooting in the state's history.

Denny Hamlin, another of the playoff contenders, finished third, while Brad Keselowski was fifth and Ryan Blaney sixth. Chase Elliott finished eighth, and his teammate Jimmie Johnson dealt with a loose car all day and finished 27th.

Keselowski dropped from third to fourth in points, 57 behind Truex. Hamlin is fifth in the standings, followed by Ryan Blaney, Elliott and seventh-time Cup champion Johnson.

Elliott knows that feeling, having been in the lead and two laps shy of the checkered flag at Martinsville before getting wrecked by Hamlin. Instead of the possible win then that would have clinched a championship spot, he now likely has to win at Phoenix to advance.

"Yeah, I guess. ... I assume so," Elliott said. "We'll just go on to Phoenix. We are going to try our best, try to get a victory and go on to Homestead."

Harvick felt good about his car all day, but had to earn the victory in Texas. Tony Stewart, the former Cup champion and car owner, liked what he saw in those last 20-25 laps.

"It wasn't just the fact of winning this race, but it's just how it was won," Stewart said. "I know Kevin, and I can tell watching his driving style, there's something that field and those other three guys that are going to make it to Homestead here in a couple of weeks, they've got something to be worried about."

After several laps chasing down Truex, Harvick was eventually able to get around the No. 78 when he executed on a cue he had taken from watching Kyle Larson driving really deep into turn one 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."

Then to Victory Lane and a championship shot.

JIMMIE'S TOUGH DAY: Johnson got to Texas only three points out of the top four, and had won there for the seventh time last spring. 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 place, his second-worst finish in his 29 Texas races.

RED FLAG: There was a red flag with 50 laps left after the No. 42 driven by Larson, who won the second stage and led 74 laps Sunday, got loose in Turns 1 and 2 and slammed hard into the wall. There was fire coming out of the rear of the car by time it came to rest on the backstretch.

ANOTHER DNF: It was the third straight race Larson wasn't able to finish. The first of those DNFs was two weeks ago at Kansas, when an engine issue led to his elimination from championship contention. He had gone into the playoffs second in points.

FINALE WHERE HE GOT FIRST: Dale Earnhardt Jr. got his first Cup Series victory at Texas in 2000, when he was a 25-year-old rookie driver. That is still the only of his 26 career victories that came in Texas. In his 30th start at Texas on Sunday, Earnhardt briefly led near the midpoint of the race during a cycle of green-flag stops. But he finished 35th, 30 laps off the pace, after having to go to the garage with about 90 laps left to replace the front left hub on the No. 88 Chevrolet.

AAA AGAIN: Texas Motor Speedway and AAA announced Sunday that the national insurance company and auto club has signed another multi-year renewal as title sponsor for the track's fall race that is part of the NASCAR playoffs. The title sponsorship began in 2010.

UP NEXT: The final elimination race at Phoenix, with five playoff contenders left and only one championship spot for the Nov. 19 finale at Homestead.