Fort Worth, Texas — Denny Hamlin had such a fast car at Texas Motor Speedway that he was able to win even after two penalties on pit road and some other issues during green flag conditions.

While Hamlin was reviewing all that happened, crew chief Chris Gabehart leaned forward and said, “I think you passed 327 cars by my count, but maybe not.”

Hamlin, who once missed the entry to pit road and also ran out fuel during the race, did do a lot of passing to get to Victory Lane on Sunday. He led the final 12 laps and 45 overall to overcome those miscues and the penalties — one when he exited pit road too fast early in the day and another for a debatable tire violation against his team during a stop just past the halfway point.

“I was just beating my head against the steering wheel thinking, ‘Man, we’re going to finish bad with a really fast race car,’” Hamlin said. “We just kept digging and Chris kept doing a good job encouraging us we had a long way to go. We kept passing cars and passing cars.”

Hamlin’s No. 11 Toyota finished more than 2.7 seconds ahead of Clint Bowyer. The 334-lap race at the 1½-mile track, with only three cautions outside the two stage stoppages, featured 27 lead changes among 13 drivers.

It was the 33rd career victory for Hamlin. He won the season-opening Daytona 500 after he went winless last year to end a streak of 12 consecutive seasons getting into Victory Lane.

His third win at Texas was his first since sweeping both races at the track in 2010.

Gibbs drivers have won four of the seven races this season, and Team Penske won the other three.

All four Stewart-Haas Racing finished in the top eight, led by Bower and Daniel Saurez finishing third. Aric Almirola and Kevin Harvick were seventh and eighth.

Erik Jones (Byron, Mich.), another Gibbs driver, finished fourth and polesitter Jimmie Johnson was fifth, just ahead of his Hendrick Motorsports teammate William Byron. Kurt Busch was ninth and JGR driver Kyle Busch finished 10th despite leading a race-high 66 laps in his attempt for a tripleheader weekend sweep.

Kyle Busch led six times, and was still in front with 59 laps to go when his No. 18 Toyota drifted high going into Turn 2.

“It just busted loose on me, and I had to catch it and make sure we didn’t crash,” he said. “First and foremost, we did that.”

While he avoided contact then, he slipped back to fourth. When trying to get back in front a few laps later, he brushed the outside wall and fell a lap behind after having to go to pit road.

For the second time in a month, he missed out on a tripleheader sweep after going into the Cup race following Xfinity and Truck Series races in the same weekend. He completed such sweeps twice at Bristol, in 2010 and 2017.

It was the third time at Texas that Kyle Busch won the Xfinity and Trucks Series races before coming up short in the weekend-ending Cup race. That also happened to him at his home track in Las Vegas four weeks earlier.

While Johnson’s career-worst winless drought reached 66 races, he started from the pole for the first time since 2016 and led 61 laps, more than he had combined since the end of the 2017.

Johnson led 40 laps all of last season, and had led only four in the first six races this year in the No. 48 Hendrick Motorsports Chevrolet that hasn’t been to Victory Lane since Dover in June 2017.

“We are definitely moving in the right direction. Car was good in clean air and had a lot of speed in it, so I think we have found kind of center for our cars and what has to happen,” Johnson said. “We’ve had a lot of pressure on us, and everyone has stepped up and getting it done.”

Along with strong finishes by Johnson and Byron, Chase Elliott was 13th. Alex Bowman was 18th in a backup car.

“I feel much better about things,” Johnson said.

Joey Logano and Brad Keselowski (Rochester Hills) have the three wins for Team Penske this season, but it was a tough day at Texas.

Logano won the first 85-lap stage, and at that point was the only driver who had scored in every stage this season. That scoring streak ended in the second stage, when he slipped to 15th after a penalty on pit road for an uncontrolled tire.

There were also issues with a loose hood wavering on the windy day and Logano, who won at Las Vegas, finished 17th at Texas, two spots ahead of teammate Paul Menard.

Keselowski, a two-time 2019 winner coming off a win at Martinsville, was scrubbing tires for the restart before the second stage when he said “something in the back of the car broke.” After extended time to repair the car, he got back out and finished 36th in the 39-car field, 55 laps behind Hamlin.

Ryan Blaney led 45 laps in his Penske Ford, but finished 37th because of overheating after 225 laps.

Blunder helps Hamilton

Lewis Hamilton’s surprise win for Mercedes at the Bahrain Grand Prix was the latest present from rival Ferrari, served on a silver plate and wrapped with a red ribbon.

Hamilton won at a canter despite the Silver Arrows lagging behind the red Ferraris for most of the race.

First, Sebastian Vettel imploded under pressure from Hamilton, spiraling out of contention some 20 laps from the end as the pair of five-time Formula One champions fought for what seemed like second place.

Then it got even worse for Ferrari as race leader Charles Leclerc’s engine started losing power.

“(It was) just a loss of power, completely,” Leclerc said. “There were no signs before.”

It was the F1 equivalent of an open-goal in soccer for Hamilton, who took full advantage before getting a post-race hug from former Manchester United and England star David Beckham, who waved the checkered flag on Hamilton’s 74th career win. Only seven-time F1 champion Michael Schumacher has more with 91.

Leclerc finished third behind Valtteri Bottas as Mercedes somehow clinched a second straight 1-2 from two races, having been slower than Ferrari in preseason testing and in Bahrain. Ferrari looked in ominous form after dominating every practice session and every section of qualifying on the 5.4-kilometer (3.3-mile) desert circuit.

A despondent Leclerc thought he was going to become the third-youngest winner of an F1 race — after Max Verstappen and Vettel — having already become the second youngest to qualify on pole after Vettel.

“You have a dream since childhood, your first win in Formula One,” the 21-year-old driver from Monaco said.

Red Bull’s Verstappen placed fourth with Vettel crossing in fifth.