RICHMOND, VA. – Joey Logano smiled as if he'd stolen something and got away with it. And that wasn't far from the truth.

Logano passed distracted and dominant Penske Racing teammate Brad Keselowski on one restart and then pulled away on another with about 20 laps to go to win the Monster Energy NASCAR Cup Series race at Richmond International Raceway on Sunday.

"We were just fast enough to break through and kind of steal a win," Logano said. "We had a decent car. We were in the lead when the caution came out there, and we looked like we were in pretty good shape, and then, obviously, to have the good pit stops and all that, I don't know if you'd call that stealing. We didn't get lucky. We were able to just do what we know how to do."

Logano, who qualified fifth but had to start 37th after making a transmission change, grabbed the lead when Keselowski had to make a defensive move to keep Kyle Busch from passing him on the inside. Logano's 18th career victory came in his 300th start.

"I was driving my guts out out there," Logano said in Victory Lane. "That's all I had. We won with a car that may not have been a winning car, so that's something to be very proud of as a team. That means the execution was there.

"Brad was the fastest car. He was so fast."

Keselowski got stuck behind some slower cars on the final restart, letting Logano pull away by nearly 2 seconds. "I think what we needed was about 10 more laps," said Keselowski, who led six times for 110 laps

On the final restart, Logano had to get around Kyle Larson and five others who stayed on the track when everyone else pitted. He made quick work of that challenge and pulled away while Keselowski and Denny Hamlin got caught in traffic dueling for the second position.

Keselowski held on for second, followed by Hamlin, Ricky Stenhouse Jr. and Kevin Harvick.

"We just didn't have the speed that the other cars had," a frustrated Hamlin said. "We finished right where we should have."

Ryan Newman, Jimmie Johnson and Dale Earnhardt Jr. all took a chance and stayed on the track when the rest of the field started making green-flag stops with about 80 laps to go. Johnson eventually pitted, but brought about the caution when he sideswiped Earnhardt into the wall in the backstretch.

Pole-sitter Matt Kenseth led the first 163 laps, winning Stage 1, and raced in the top 10 until a flat tire with 35 laps to go.