RICHMOND, Va. — Justin Allgaier gave up the lead, bided his time and then took it back.

Allgaier caught front-running Justin Haley with 29 laps to go Friday night and held him off the rest of the way to win the NASCAR Xfinity race at Richmond Raceway, giving him his second victory of the season and perhaps signalling an end to his recent frustration.

He wasn't sure when to make a move back to the front, but it worked out.

"I didn't know when it was time, to be honest with you," Allgaier said about becoming more aggressive. “He pushed the pace there early on and these guys did such a fantastic job.”

Richmond has baffled him previously, making the victory all the more satisfying.

“I feel like we've had so many get away here and just haven't been able to seal the deal. It's been so frustrating,” he said, adding that nothing has changed from his recent frustrations except "we just had the luck that we needed.”

Allgaier had held the lead for 49 laps before Haley passed him and pulled away, building a lead of nearly 3 seconds in his 48 laps in front before getting caught in lapped traffic as his lead dwindled. Allgaier finally pulled to his outside on Lap 220 and they raced side-by-side before Allgaier reclaimed the top spot and held on, winning by 0.604 seconds.

“I obviously tried to save as much as possible. They wanted me to back it down and I kept backing it down,” Haley said of the long run at the end. “I wasn't slipping no tires so I didn't think there was an issue, but Allgaier was just a ittle bit better.”

Kyle Busch started 29th and eventually worked his way into contention, but he never led and finished third, followed by series points leader Austin Cindric and pole-sitter Ross Chastain. Michael Annett, who finished seventh, became the ninth driver to secure a spot in the series playoffs with two races remaining in the regular season.

Busch said he was saving his car for a push at the finish, “but I knew if I pushed any harder earlier in the run in order to get there I'd just have nothing at the end. I tried to go with about 18 to go there and try to get a little but closer and was able to knock off a half a second at least, but that was it and she was smoked after that.”

The race was the start of a series doubleheader weekend at Richmond, with the second race to be held Saturday as a prelude to the Cup series taking the track at night.

“I can't be more excited to go tomorrow,” Allgaier said.

Cindric won the 75-lap first stage, passing Chase Briscoe for the lead with 15 laps to go. Cindric took advantage of a competition caution after 40 laps to get new tires while some drivers stayed out. It was his series-best 10th stage win.

Allgaier passed Cindric with 26 laps to go in the second stage and pulled away for his ninth stage win of the season. Cindric had led for 44 lap of green-flag racing until Allgaier finally caught and passed him and pulled away to open a wide lead.

Chastain. Busch and Haley all passed Cindric too, as his car seemed to fall off significantly at the end of the long green-flag run.

___

More AP NASCAR: https://apnews.com/NASCAR.