RICHMOND, Va. (AP) — Joey Logano won Sunday's Monster Energy Cup race at Richmond despite starting near the back of the line.

Logano pulled away after a restart with about 20 laps to go and finished ahead of teammate and runner-up Brad Keselowski. Logano qualified fifth but had to start 37th after making a transmission change.

Keselowski had the dominant car for the second half of the race, but he got stuck behind some slower cars on the late restart, letting Logano pull away.

Denny Hamlin was third, followed by Ricky Stenhouse Jr. and Kevin Harvick.

Pole-sitter Matt Kenseth led the first 163 laps to win Stage 1 and raced in the top 10 all day until a flat tire with 35 laps to go. He finished 23rd.