The temperatures were right for Denny Hamlin. The tires were wrong for Martin Truex Jr.

Denny Hamlin celebrates his second victory of the season after Sunday's STP 400 at Kansas Speedway. Hamlin and Tony Stewart each have two wins in 2012.

It might seem facile to claim the STP 400 was decided solely on a fortuitous weather development for the winner and a frustrating set of tires for the runner-up, but that's essentially what happened.

Hamlin led the final 32 laps at Kansas Speedway, passing Truex shortly after his No. 11 Toyota came to life when the sun began shining on the 1.5-mile oval for the first time Sunday afternoon.

The Joe Gibbs Racing driver credited the track getting slicker in the midday heat as a critical factor in his second victory of the season and the 19th of his Sprint Cup Series career.

"I felt like our car was maybe one of the best cars in practice when the sun was out," said Hamlin, whose crew chief, Darian Grubb, was left scrambling Saturday when the high temperature for Sunday's forecast dropped by 10 degrees. "It was probably 70 degrees, and the track was slick when the sun came out (Sunday). It put our car back to right where it was in practice."

While Hamlin was surging, Truex's Toyota was beginning to slump despite leading 173 of 267 laps in a clean race that set a track speed record (144.122 mph) with only three cautions for 18 laps.

Michael Waltrip Racing's No. 56 team made its final stop under green on lap 221, and Truex immediately knew something was wrong. For 25 laps, he struggled to keep his Camry beneath him while being stalked and then passed by Hamlin.

Truex's car stabilized but he couldn't overcome the gap. He and Hamlin ran similar speeds over the final 20 laps as cloud cover returned, but Truex said that didn't factor into his worsened handling.

"I don't know what happened with the last set of tires; they were terrible," said Truex, whose team didn't make any significant chassis adjustments before the stop. "I couldn't go at all. … There was really no rhyme or reason to it."

Moving up two spots to second in the points standings (he trails Greg Biffle, who finished fifth, by 15 points) was of little solace to the two-time Nationwide Series champion, whose lone win in NASCAR's premier series (and only Chase for the Cup appearance) was five years ago.

"I felt (it) was kind of a day where I was back," Truex said. "As disappointed as I am with second, this is a big day for us. It's kind of a statement (that) we're here for the long haul. We're not just a flash in the pan."

"We've been solid each week, and I know our wins are going to come. We just need to keep running like we are."

There was a significant takeaway for Hamlin, too. Heading into his hometown race at Richmond International Raceway, the driver from Chesterfield, Va., scored the 199th victory in NASCAR's premier series for the No. 11 — breaking a tie with the No. 43 for most wins all-time by a car number. Among the legends who drove the No. 11 to victory lane are Cale Yarborough, Ned Jarrett, Darrell Waltrip and Bill Elliott, Hamlin's childhood hero.

"It's kind of a tribute to them," Hamlin said. "They're the ones that put this car number on the map. I was just a small part of that history.

"I just hope that I live up to the standards because there's been some great drivers, and I'm just living on the legacy."

Jimmie Johnson Matt Kenseth and Biffle rounded out the top five. The were followed by Kevin Harvick, Dale Earnhardt Jr., Kasey Kahne, Carl Edwards and Kyle Busch.

Earnhardt's victory drought was extended to 137 races but is fourth in points, 21 behind Biffle.