AP photo by Darron Cummings / AJ Allmendinger celebrates after winning Sunday's NASCAR Cup Series race on the road course at Indianapolis Motor Speedway.

INDIANAPOLIS — AJ Allmendinger screamed in elation after winning Sunday's NASCAR Cup Series race at Indianapolis Motor Speedway.

Just about every other driver left the famed motorsports venue frustrated, angry or bewildered by a bizarre Brickyard 200 finish that involved 16 wrecked cars, two red flags, a spinout of the race leader and a penalty — all in the final five laps — to help Allmendinger reach victory lane.

The 39-year-old Allmendinger beat Ryan Blaney across the yard of bricks by 0.929 seconds to pick up the second win of his Cup Series career in his fourth start of the season. It also was the first win for Kaulig Racing in the team's seventh start.

"Oh my God, I just won at Indy. Shank, I just wanted to be like you," Allmendinger shouted to the crowd, referencing Michael Shank, the IndyCar team owner whose organization won the Indianapolis 500 this year with veteran Hélio Castreneves behind the wheel. "It was just survival of the fittest."

Allmendinger's other victory also came on a road course at Watkins Glen International in 2014.

The 14-turn, 2.439-mile road course at IMS certainly proved to be a challenge for everyone on this wild crossover weekend. After watching one IndyCar and two NASCAR Xfinity Series drivers go airborne in the sixth turn Saturday, track officials removed the "turtle" there.

On Sunday, drivers were having trouble with the chicane in the back-to-back fifth and sixth turns. The damaged obstacle, NASCAR officials said, had deteriorated by the end of the race. Whether that was because of three consecutive days of practice, qualifying and racing was unclear.

Track workers still attempted to fix it during the race and once pulled a three-foot metal piece from underneath it.

When William Byron ran over the curbing with five laps left, it was chaos. The pole position winner's No. 24 Hendrick Motorsports Chevrolet veered off course, and eight more drivers quickly followed him, immediately bringing out a caution and eventually the first red flag.

"It was so weird," said Byron, who first noticed it when Kyle Larson's car went over the obstacle ahead of him. "I nailed something and it tore it up."

This time, the track workers pried it loose and towed it away to the sound of cheering fans. Even track president Doug Boles pitched in by grabbing a shovel and broom to help clean up in his suit and tie.

When the engines restarted, nobody knew what to expect or how to navigate the altered course. And the next time through the turn, seven more cars were involved in the pileup, bringing out another red flag. NASCAR officials did not report any serious injuries.

"There was some debate about whether to continue and whether to take the other one out," NASCAR vice president of competition Scott Miller said. "When we tested there last year, that section was way too fast, so we weren't going to sign up for that, so we keep the other one."

The drama was just beginning. With Denny Hamlin in the lead on the final restart, Chase Briscoe's second-place car went skittering through the grass between the first two turns and back onto the track. The two raced side by side briefly before Hamlin pulled slightly ahead heading into the 10th turn.

That's when Briscoe spun out Hamlin, apparently unaware he had been assessed a penalty. Hamlin finished 23rd but dropped to second place in the season points standings because after Larson finished third, Briscoe wound up 26th.

"Just a lack of awareness," Hamlin said. "I don't think he did it maliciously. He's not that kind of person. This just turned everything upside down."

Actually, things were upside down all day at a race that seemed more apt for a short track.

At one point, Brad Keselowski hit a concrete wall and pitted with the back part of his car dragging. Several cars used duct tape to keep parts together, and while some drivers inadvertently wound up in the grass, others were punted off the track. And after the big melee, the damage was evident up and down the line of stopped cars.

Somehow, in the midst of all of it, Allmendinger made his way to the front and led only two laps — the last two.

"I was so mad yesterday because I wanted to win so bad," he said, dedicating the victory to familiar racing media figures Bob Jenkins and Robin Miller. "I never could have imagined this is how this would play out."

Tyler Reddick won the first two stages, gaining crucial points toward a playoff spot. He beat Richard Childress Racing teammate Austin Dillon to the yard of bricks both times, with Dillon finishing third in the first stage and moving up one spot in the second.

Many drivers from all three series lined up to watch other drivers compete over the weekend. IndyCar driver Rinus VeeKay watched from the infield Sunday, and Ryan Hunter-Reay stuck around, too.

But none embraced the crossover opportunity more than Daniel Suarez and IndyCar championship contender Pato O'Ward, who did their formative driving in Mexicco.

"I haven't seen him in so long, it was really really nice to see him," O'Ward said after finishing fifth Saturday. "I hope we can get to more race tracks together because we started at the same race track. He's a great, great guy, great family. I've always enjoyed having him around."

The Cup Series returns to an oval next Sunday at Michigan International Speedway.