Ryan Blaney finally had the car he needed to claim the win that had evaded him all year.

But after dominating Iowa Speedway's short oval all night Saturday, Blaney was forced into a flurry of late restarts and two green-white-checkered finishes.

Blaney maintained his composure and clinched a win he had deserved from the opening lap.

Ryan Blaney survived four cautions in the last 24 laps to win the NASCAR XFINITY race for his first victory of the season.

"It's not ideal at all. You have a great car, and those late cautions are just chances to give it away," Blaney said. "That's what makes it stressful. You've got to stay focused on the task at hand."

The 21-year-old Blaney erased the sting of a disappointing runner-up finish last week in Indianapolis by maintaining his lead through a second green-white-checkered finish on the 0.894-mile oval.

Blaney led a track-record 252 laps -- two more than were originally scheduled -- and won after finishing second three times in his other six XFINITY starts this season.

Regan Smith was second, followed by Brian Scott, Ty Dillon and Brendan Gaughan.

"It's crazy that you lead more laps than the race is actually scheduled for. First I've heard of that," said Greg Erwin, Blaney's crew chief. "Last week, that's over. That's done with...he dominated the race."

Fifty-one-year-old Kenny Wallace, the career XFINITY starts leader with 547, finished 15th in the last race of his NASCAR career.

Blaney, whose miscue on the final lap last week in Indianapolis allowed Kyle Busch to slip past him for the win, cruised past pole-sitter Daniel Suarez on the opening lap.

The clean air helped Blaney take control for 75 laps -- an Iowa record for green-flag laps.

If only the end was as easy as the beginning.

Blaney had to endure multiple restarts as championship contenders Chase Elliott, Chris Buescher and Darrell Wallace Jr. got involved in incidents.

Blaney and Gaughan then rubbed on the first green-white-checkered finish, with Blaney holding off the No. 62 before yet another wreck.

Blaney suffered damage to a rear tire prior to the final restart, but he held on and crossed the finish line with smoke coming from his No. 22 car.

"That's what people want to see is good, hard racing for wins -- and that's what we were doing. There are no hard feelings there at all," Blaney said.

Suarez was sixth in his attempt to become the first Mexican-born driver to win in the series.

Elliott was ninth, Darrell Wallace 11th and points leader Buescher 13th.

Buescher lead over Elliott, last year's champion, dropped from 25 to 20 points.

All those late accidents led to multiple pit road arguments, including a heated exchange between Ross Chastain and Ryan Reed.

"I think it's interesting. Tempers were flaring that much (Saturday)...these next four weeks could be as interesting as hell. We all might need boxing gloves and boxing lessons before it's over," Smith said.

Kenny Wallace won nine times in NASCAR's second-tier series, and he qualified a seventh in the powerhouse Joe Gibbs Racing No. 20 car.

But Wallace quickly fell back to the pack, and he got loose into the second turn with just 40 laps left.

Wallace finished his XFINITY career after 26 seasons with 10 poles and 173 top-10 finishes, good for seventh-most in the series.