AP photo by Ralph Freso / Martin Truex Jr., right, and Brad Keselowski come out of the second turn at Phoenix Raceway during Sunday's NASCAR Cup Series race in Avondale, Ariz.

AVONDALE, Ariz. — Joey Logano has won a few times at Phoenix Raceway and knows a good restart when he feels one. With 25 laps to go Sunday, he got a good run on the green flag, dipped down low on the dogleg and felt great.

Then he realized Martin Truex Jr.'s No. 19 Toyota was still right next to him. That was a big problem.

Truex blew past Logano on the final restart and pulled away for his first NASCAR Cup Series victory of the season and the 28th of his career. That set off a hearty celebration from his Joe Gibbs Racing team, especially after a frustrating 2020 season that included just one win.

"I'd say we were really hungry for it," Truex said. "We really wanted it, obviously. We worked really hard, we've got a great team and it just seemed like for whatever reason, it was always little things biting us. We were always so close, always second or third."

This time he was first. By a lot.

The 40-year-old driver, who won the 2017 season title with Furniture Row Racing before that team shut down at the end of 2018, beat the four championship finalists from last year. Last November at Phoenix marked the first time in four years Truex was not one of the drivers eligible for the title in the season finale, and he could only watch as Chase Elliott beat Logano, Denny Hamlin and Brad Keselowski for the title at the desert oval.

On Sunday, all four tailed Truex across the finish line at the track that will again host the finale with the title at stake this fall.

"To come here and win this, I wish it was November," Truex said. "Hopefully we can come back in November and have a shot at the championship."

Truex struggled to a 25th-place finish in the season-opening Daytona 500 and was 12th the following week on the road course at Daytona International Speedway, but he had since finished third at Homestead-Miami Speedway and sixth at Las Vegas Motor Speedway. He was dominant during the final half Sunday and became the second driver from last year's 16-car playoff field to qualify for the postseason after a surprising run of winners to start the 2021 schedule.

Logano, who led 143 laps in the Team Penske No. 22 Ford, won the second stage after leading the final 35 laps during a long stretch of green-flag racing, but he couldn't hold back Truex, who won for the ninth time since joining JGR. Logano held for second, JGR's Hamlin was third, Penske's Keselowski was fourth, Hendrick Motorsports' Elliott was fifth. Stewart-Haas Racing's Kevin Harvick, another regular championship contender, was sixth as the earlier parity faded a bit more.

Logano said even if he was able to hold Truex on the restart, he probably would have been passed by the No. 19 before the checkered flag.

"They just had a fast car," Logano said.

Truex, who announced a contract extension with JGR days before the season began, rebuked questions about retirement before he'd even been asked. After last year's one-win season, there had been speculation the veteran was contemplating walking away. However, Truex also finished second or third 11 times in 2020 and missed being one of the final four drivers for just the second time in six years.

Kyle Larson — who raced to his first victory with Hendrick a week earlier in Las Vegas — had to start at the back of the field after his car failed inspection before the race. He worked his way back to the front and briefly led about halfway through before getting flagged for speeding on pit road. He had to pass through pit road as a penalty, causing him to fall to the back of the lead lap in 22nd place. He finished seventh.

Hamlin was fast early in the race, leading for 31 laps until the competition caution midway through the first stage. He fell back a few spots after a pit stop that allowed Ryan Blaney a window to get to the front of the field. The Penske driver won the 75-lap first stage after leading 35 laps.

Truex enjoyed getting the win in front of some fans in Phoenix. The track allowed about 20% of the grandstand to be filled. Phoenix was the site of the last "normal" Cup Series race in March 2020 before COVID-19 shut down NASCAR for about two months.

"Most we've seen in a while, and the more the merrier," Truex said. "We love having them, we miss seeing them, we miss seeing them in the infield, we miss prerace, we miss practice, we miss qualifying, just like everyone else."

Next weekend's race is at Atlanta Motor Speedway, where Harvick won last season.