AVONDALE, Ariz. — Kevin Harvick led throughout the final stages of the Good Sam 500 NASCAR Sprint Cup Series race at Phoenix International Raceway on Sunday en route to his first win of the season in a photo finish over Carl Edwards.

Harvick captured his eighth career win at the track, the most all time of any driver, and his sixth Phoenix win in the past eight races.

Edwards crossed the finish line .01 of a second behind Harvick. Edwards’ Joe Gibbs Racing teammates, Denny Hamlin and Kyle Busch, finished third and fourth, respectively.

Dale Earnhardt Jr. rounded out the top five after restarting on the front row next to Harvick for the final two green-flag laps of the race. Harvick, Earnhardt and Austin Dillon were on older tires ahead of everyone else potted for at least two when the yellow flag waved for the final time with six laps to go in the 312-lap scheduled distance.

Harvick first took the lead on a restart that followed a lap-163 yellow flag and led throughout the remainder of the race, except when Edwards beat him off pit road during a caution that came out with 87 laps to go. When the race restarted, though, Harvick reclaimed the lead.

Edwards’ No. 19 Joe Gibbs Racing crew got its driver off pit road first throughout the race, with Edwards leading the train off pit road during four of five cautions.

Busch started on the pole and led the first 74 laps of the race before Earnhardt got by him.

Earnhardt started the race in the 26th spot but had the fastest car on the track throughout the opening laps. He was inside the top five by the first time the yellow flag waved on lap 52. He took second as soon as the race returned to green.

Busch was the only driver to take only two tires under the caution, but he was able to maintain his lead over drivers with four new tires until being overtaken by Earnhardt.

Edwards also led significant laps after getting off pit road first following a lap-106 caution and was running up front until Harvick took the lead for the first time.

The yellow flag waved five times in the race, with all the cautions seeming to be at least partly caused by tire issues. Most of those tire issues were a result of excessive braking that created so much brake dust that teams routinely cleaned their pit stalls with leaf blowers.

NOTES: Joe Gibbs Racing swept the top three in qualifying on Friday, with Kyle Busch taking the race pole and Carl Edwards and Denny Hamlin the second and third starting spots. … JGR also dominated the NASCAR Xfinity Series race at Phoenix International Raceway on Saturday, with Busch winning after leading 175 of 200 laps and Gibbs drivers Erik Jones and Daniel Suarez finishing second and third. … Jimmie Johnson qualified fifth on Friday, but because of a wreck late in the qualifying session when his steering wheel came off, he started the race in the back in a backup car. He finished in 11th place. … Martin Truex Jr. was without suspended crew chief Cole Pearn. Todd Berrier substituted for Pearn. … Dale Earnhardt Jr. was the most recent winner at Phoenix, winning there in November 2015. He is a three-time winner at PIR.