Jeff Gordon scored his first NASCAR Sprint Cup race win of 2013 at Martinsville, as title rivals Matt Kenseth and Jimmie Johnson drew level in the standings.
Gordon passed Kenseth for the lead with 20 laps remaining in a bruising race that featured a season-high 17 caution periods.
Johnson, Gordon, Kenseth, Clint Bowyer and polesitter Denny Hamlin had been the main lead protagonists as the race order repeatedly shuffled through divergent strategies amid the seemingly endless yellows.
Kenseth's Joe Gibbs Toyota dropped down the order mid-race but worked his way back to lead going into the closing stages.
Hendrick driver Gordon managed to get down the inside of Kenseth on lap 480 of 500 following a long battle, and then edged out just enough breathing space amid heavy traffic.
As Gordon won by half a second, Bowyer's Waltrip Toyota closed in on Kenseth and came within 0.064s of stealing the runner-up spot.
Brad Keselowski beat Johnson to fourth place, meaning Kenseth and Johnson are now level on 2294 points with three races to go.
After the race Johnson was involved in a heated argument with Greg Biffle, the pair having made contact repeatedly during a late dice. Biffle finished ninth.
Kevin Harvick took sixth, ahead of Denny Hamlin and Dale Earnhardt Jr.
Results - 500 laps: Pos Driver Team/Car Time/Gap 1. Jeff Gordon Hendrick Chevrolet 3h44m21.000s 2. Matt Kenseth Joe Gibbs Toyota +0.596s 3. Clint Bowyer Waltrip Toyota +0.668s 4. Brad Keselowski Penske Ford +4.698s 5. Jimmie Johnson Hendrick Chevrolet +5.321s 6. Kevin Harvick Childress Chevrolet +10.891s 7. Denny Hamlin Joe Gibbs Toyota +11.553s 8. Dale Earnhardt Jr Hendrick Chevrolet +12.219s 9. Greg Biffle Roush Fenway Ford +13.806s 10. Jamie McMUrray Earnhardt Ganassi Chevrolet +16.207s 11. Jeff Burton Childress Chevrolet +17.360s 12. Carl Edwards Roush Fenway Ford +17.541s 13. Juan Pablo Montoya Earnhardt Ganassi Chevrolet +17.930s 14. Joey Logano Penske Ford +19.010s 15. Kyle Busch Joe Gibbs Toyota +19.911s 16. Martin Truex Jr Waltrip Toyota +20.731s 17. Danica Patrick Stewart-Haas Chevrolet +1 lap 18. Kurt Busch Furniture Row Chevrolet +1 lap 19. Marcos Ambrose Petty Ford +1 lap 20. Aric Almirola Petty Ford +1 lap 21. Casey Mears Germain Ford +1 lap 22. Paul Menard Childress Chevrolet +1 lap 23. David Gilliland Front Row Ford +1 lap 24. Travis Kvapil BK Toyota +1 lap 25. Elliott Sadler Waltrip Toyota +1 lap 26. Michael McDowell Parsons Ford +2 laps 27. Kasey Kahne Hendrick Chevrolet +3 laps 28. Ken Schrader FAS Lane Ford +4 laps 29. Landon Cassill Hillman Chevrolet +5 laps 30. JJ Yeley Baldwin Chevrolet +5 laps 31. Ricky Stenhouse Jr Roush Fenway Ford +5 laps 32. Bobby Labonte JTG Daugherty Toyota +6 laps 33. Joe Nemechek NEMCO Toyota +7 laps 34. Josh Wise Front Row Ford +10 laps 35. Cole Whitt Swan Toyota +41 laps 36. Mark Martin Stewart-Haas Chevrolet +45 laps Retirements: David Reutimann BK Toyota 451 laps Ryan Newman Stewart-Haas Chevrolet 432 laps* Dave Blaney Baldwin Chevrolet 357 laps Reed Sorenson Leavine Ford 275 laps Tony Raines Circle Sport Chevrolet 220 laps Kyle Larson Phoenix Chevrolet 160 laps David Ragan Front Row Ford 109 laps * Running again at chequered flag