Albert Reid scores on a two-point conversion to give Virginia a 25-24 lead over No. 5 Louisville with less than two minutes left. (Ryan M. Kelly/Associated Press)

Lamar Jackson hadn’t been himself all day, and Virginia’s defense had been good enough to lay the groundwork for an upset over No. 5 Louisville at Scott Stadium. But Virginia’s final touchdown and daring two-point conversion to take the lead left the Heisman Trophy front-runner too much time — 1 minute 57 seconds — to squeeze out a win.

Jackson hit Jaylen Smith with a 29-yard touchdown pass and again for a two-point conversion with 13 seconds remaining to eke out a 32-25 win in Charlottesville, saving Louisville from a shocking upset and leaving Virginia with a familiar, bitter taste of what could have been.

“We threw our best punch today,” senior linebacker Micah Kiser said. “We’re gonna keep throwing our best punches.”

Until the final seconds, Kiser led a surprisingly stellar defense that appeared poised to mar Jackson’s Heisman campaign and his team’s College Football Playoff hopes.

Virginia fans are deflated by Lamar Jackson’s game-winning touchdown pass with 13 second remaining. (Ryan M. Kelly/Associated Press)

Jackson completed 24 of 41 attempts for 361 yards and four touchdowns with one interception, but was held without a rushing touchdown for the first time this season and was sacked five times.

Virginia (2-6, 1-3 ACC) led for much of the afternoon before Louisville scored 17 consecutive points to take a 24-17 lead midway through the fourth quarter. Quarterback Kurt Benkert and the Cavaliers’ offense responded with what appeared to be a defining drive, and the coaching staff made a decision they hoped would define the program.

Virginia moved 75 yards in 14 plays, converting two fourth downs. On the second, fourth and seven on Louisville’s 34-yard line, Benkert completed a 30-yard pass to Keeon Johnson.

For the first time all day the transfer quarterback seemed calm when he hit wide receiver Doni Dowling with a touchdown pass on the next play.

The Cavaliers’ players were hoping their coaches would tell them to try for the two-point conversion. It was a play the team felt confidently about — they had run it all week in practice and never failed to score.

Virginia also wanted to assert its identity in front of the highest-ranked team to visit Charlottesville since No. 2 Oregon came to town in 2013.

“I wanted to win, and I didn’t want to go to overtime,” Virginia Coach Bronco Mendenhall said. “I wanted to win now. I wanted the team to know that I believed in them and we weren’t going to rely on anyone else, that we had an opportunity to show how we’re going to play and how the program is going to be run.”

Benkert tossed the ball to a wide-open Albert Reid for a 25-24 lead.

But after a touchback, Jackson answered by leading an eight-play, 75-yard winning drive. He ran three times for 34 yards on the on the series — boosting his final rushing total to 90 yards — and converted a fourth and three at midfield with a five-yard pass to Cole Hikutini.

“You can cover his guys all you want, but he’s faster than everyone on the field,” Kiser, who had a team-high 14 tackles and two sacks, said of Jackson with a laugh. “We did our best, but I mean at the end of the day, he can outrun everyone.”

Louisville (7-1, 5-1) outgained Virginia 508 yards to 322. Benkert completed 25 of 39 passes for 238 yards and three touchdowns, but threw two costly interceptions, one of which turned into a touchdown that gave Louisville its first lead of the afternoon early in the fourth quarter.

In the first half, Virginia’s defense played its best 30 minutes of the Mendenhall era to hold Louisville to its lowest-scoring half this season. The Cavaliers held a 10-7 edge going into halftime and were more technically sound than Louisville’s sputtering offense, which gained 261 yards but suffered too many dropped passes and too many penalty yards.

Mendenhall’s defense allowed Louisville to convert just 3 of 12 third downs for the game. Adding huddles into offensive coordinator Robert Anae’s usually speedy, no-huddle scheme helped slow Louisville and gave the defense a chance to catch its breath.

Virginia held the ball for 32:18 compared to the Cardinals’ 27:42.

“Defensively I think that was our best game,” Kiser said. “Executing on defense, really doing what Coach Mendenhall wanted us to do . . . this is still a lot of young guys playing, if you look at our defensive line it’s a lot of freshmen like Eli Hanback, guys that haven’t really played much, especially in the secondary. It’s a gradual process, and we’re getting better.”