BRISTOL, Tenn. (AP) — AJ Allmendinger slid sideways across the Bristol Motor Speedway finish line to edge rival Austin Cindric for both the Friday night win and the NASCAR Xfinity Series regular-season championship.

The race was Cindric's to win and the reigning Xfinity champion was four laps away from a second straight regular-season title and a healthy lead for the start of the playoffs. Instead, a late caution gave Allmendinger a shot to steal a sixth win from Cindric and continue his own fairytale season.

The rivals crashed each other as the cars crossed the finish line and Allmendinger's fourth win of the season was awarded because his Chevrolet was sliding ahead of Cindric's under the checkered flag.

The wreck was a wild way to send the Xfinity Series into the playoffs.

“It's frustrating to get hit that hard coming to the checkered, but we are battling for the win and it's Bristol baby, this is what it's all about," Allmendinger said to a roaring crowd. "I haven't had a lot of chances in my life to win at Bristol, so you get a chance to go do it, you do it.

“If I don't take that chance, I don't belong in that racecar because my team deserves to win.”

Allmendinger earned a shot at the win when Justin Allgaier spun Sam Mayer with four laps remaining in regulation.

Allmendinger and Cindric were side-by-side on the restart for a frenzied two laps around the 0.533-mile concrete bullring in which Cindric, Allemdinger and Allgaier traded the lead and bounced off one another multiple times.

Allmendinger finally surged to the lead only to be caught by Cindric, again, as the two banged doors hurtling toward the checkered flag. Both cars began to spin and were sideways as Allmendinger stole the victory, and they continued to crash after the finish.

The win gave Allemendinger the regular-season title over Cindric by 10 points. More important, it tied the two at the top of the standings for the start of the playoffs next week at Las Vegas Motor Speedway.

The 39-year-old Allmendinger is in a career resurgence this season, his first running full-time again because Kaulig Racing slowly lured him back into their Chevrolet. He'd been partially retired but agreed to help Kaulig start its team.

What started as a race here, a race there, is now a full run at the championship that has captured fans who adore the enthusiastic journeyman who had a chance once to win the Indianapolis 500 only to come back last month and win NASCAR's first race on the Indianapolis Motor Speedway road course.

“I didn't expect this,” Allmendinger said. “I didn't expect this, so why not give everything you've got? You never know how much you've got left, so I'm going to run every lap like it's my last one.”

Cindric is the top seed for the playoffs based on most wins this season.

The end of the race made for an awkward atmosphere inside the Bristol stadium, where Allmendinger's celebration was delayed by a mandatory trip to the care center. That made Cindric the first driver to be heard from over the public address system and the 23-year-old was at first booed and then cheered as he seemed to flip the crowd.

“Man, what a hell of a race. I tried,” said Cindric, who briefly stopped talking when the crowd booed him for complaining Allmendinger destroyed the Team Penske Ford.

But he changed the mood when he was asked about his frustration over leading 75 laps and losing the race, as well as a second-consecutive title and the clear top seed, and to add more insult, a good car was wrecked.

“That's why there's people in the grandstands. I mean, they want to see that battle again,” Cindric said as the crowd again interrupted him.

“I just got booed. I just got cheered. I don't know what's going on.”

___

More AP auto racing: https://apnews.com/apf-AutoRacing and https://twitter.com/AP