MARTINSVILLE, Va. — Ryan Newman needed help and was running out of time. Finally, Clint Bowyer provided an opening with two laps to go at Martinsville Speedway.

Bowyer’s aggressive move took out race leaders Jeff Gordon and Jimmie Johnson entering the first turn, allowing Newman to slide into the lead, and he held off A.J. Allmendinger and Dale Earnhardt Jr. on another restart for his first win in 23 races.

“We were not a dominate race car,” Newman said. “Clint kind of cleared out Turn One for us and we were fortunate enough to be in the right place at the right time.”

The reverse was true for Gordon, who led 328 laps, and Johnson, who led 112. The Hendrick Motorsports teammates seemed poised to battle it out to see which one would give owner Rick Hendrick his 200th Sprint Cup victory, and neither had a chance in the end.

“Jeff and I had been the class of the field so I really thought it was going to be a race between the two of us, and it certainly didn’t turn out that way,” Johnson said.

He wound up 12th, and Gordon was 14th.

Of the restart, Johnson said: “That inside lane is awfully inviting at times to dive-bomb on people. The No. 15 (Bowyer) threw a dive-bomb in there. I’m sure once he got in there, he realized it wasn’t the best idea. It turned me around. It turned the No. 24 around.”

Gordon angrily sought out Bowyer after the race, and heard the whole story.

“He said he got hit from behind by the 39 (Newman),” Gordon said. “I had nowhere to go. Jimmie had nowhere to go. It was pretty unfortunate. ... I didn’t want to see that last caution. We had such a great battle with (Johnson). ... It was going to be an interesting race.

“That’s just the way our year’s been going. It can’t go on like this forever.”

Gordon improved three spots in the points standings, but is still just 22nd.

Newman’s performance drew praise from car owner Tony Stewart.

“I’m ecstatic for Ryan,” the defending series champion said. “I got to see it on the replay during the caution after all the havoc broke loose. Ryan made an awesome move to the bottom. He was heads up to get in the gas and through that hole before it closed up.”

Allmendinger was second, followed by Earnhardt, Matt Kenseth and Martin Truex Jr.

The finish overshadowed what had been a stirring duel between Gordon, a seven-time winner on the 0.526-mile oval, and Johnson, a six-time winner.

Johnson first took the lead when he passed Gordon on the 356th lap. He lost it on pit road, then passed Denny Hamlin to lead again on lap 393. He held off a modest challenge by Gordon with about 30 laps to go and then dueled side-by-side with his teammate until the caution, which came when David Reutimann ran out of gas near the entrance to turn one.

Gordon, who had just nudged in front of Johnson before the yellow flag came out, was the leader, with Johnson second and everyone behind them heading to pit road for tires.

What had been an atypically clean raced turned into mayhem on the restart.

Earnhardt, who was in position to give Hendrick a sweep of the top three spots before the caution, said everyone being on fresh tires played a factor in the crash.

“We all took off and ran into the back of the leaders, all of us,” he said.

Earnhardt had no issue with Bowyer for trying to take the inside line, saying that’s how you approach a two-lap sprint, but was at a loss to explain Reutimann’s actions.

“I would like an explanation on why that happened,” he said of Reutimann stopping where he did after having made several troubled laps without going to the pits. “There doesn’t seem like there could be a logical reason for him to have to stop on the track.”

Reutimann said his motor just died.

“I would not have stopped on the freaking racetrack. I would have limped it around there and come to pit road, which is what I was trying to do,” he said. “The thing quit going down the back straightaway, and it shut off. I just didn’t stop there intentionally.”

Greg Biffle, who finished 13th, remained the points leader by six over Earnhardt.