RENO, NEV. — Air Force’s first-ever trip to Nevada looked like it would be a successful one when Sam Gagliano dove in the end zone to catch a 22-yard touchdown pass from Karson Roberts to take a 42-30 lead with 7:44 left in the game.

But Cody Fajardo led the Wolf Pack on two late scoring drives, capped by his own 2-yard touchdown run with 1:45 remaining, to hand the Falcons their fourth consecutive loss Saturday night 45-42.

“We had it in the bag and beat ourselves,” said Gagliano, a wide receiver who didn’t catch a pass but ran twice for 75 yards and even completed a throw on a trick play for 23 yards.

“Guys are beating themselves up a little bit, but we’ll keep our heads up and keep moving forward,” he said, as the Falcons turn their attention to next week’s game at Navy.

Fajardo threw for a career-high 389 yards and three touchdowns and ran for 81 yards and two more scores to help Nevada overcome a 12-point deficit in the final 6 minutes.

Aaron Bradley caught 11 passes for 135 yards and a touchdown and Brandon Wimberly had a career-high 15 receptions for 134 yards and a score for the Wolf Pack (3-2, 2-0 Mountain West). Nevada cornerback Charles Garrett’s interception at the Wolf Pack 25 sealed the victory with less than 30 seconds left in the game.

“That was pretty wild,” said first-year Nevada coach Brian Polian, who watched a smaller Air Force team control much of the game on both sides of the ball.

“Was it perfect? Not by a long shot. But they found a way. Sometimes you play in a game and it’s ugly and you’ve just got to find a way. We found a way tonight. It wasn’t pretty. It was a character win. We showed some resiliency tonight. I’m proud of our team for that,” he said.

Roberts ran for 161 yards and two touchdowns and threw for another score, and Broam Hart added 88 yards rushing and a TD for the Falcons (1-4, 0-4).

“We missed some opportunities to make some plays, which you have to make to be able to close out a football game, especially against a quality squad,” he said.

Roberts, a sophomore who began the season as the third-string quarterback, got the start because Jaleel Awini was suspended from the team indefinitely during the week.

“Stepped into the role Coach gave me, trying to do the best that I can,” said Roberts, who scored on runs of 9 and 11 yards and completed 5 of 10 passes for 55 yards. “It was a tough fight. We both went to the wire, we wanted the win but props to Nevada.”

Trailing 42-30, Fajardo led Nevada on a 75-yard scoring drive capped by a 9-yard TD pass to Bradley to pull within 42-37 with 5:55 remaining.

Consecutive illegal substitution penalties — which Calhoun agreed were the right calls — forced Air Force to punt. But when Nevada’s Joseph Huber fumbled at the Wolf Pack 31, his teammate Randy Uzoma recovered and ran 21 yards to midfield. With 3:50 left, Fajardo passed 30 yards to Bradley, ran 9 yards and passed 8 to Wimberly before scoring on a 2-yard keeper. Jackson rushed for the 2-point conversion to put Nevada on top for good 45-42 with 1:45 left.

“I’m going to say a lot of prayers tonight, that’s for sure,” said Fajardo, whose 38 completions and 54 attempts also were career highs. “It was a team victory. … I’m pretty proud of our offense. They never panicked. We knew if we just played our game, we could score and we’d get right back into it.

“We knew the defense was going to get a stop. They did, the rest is history. We never gave up.”

It was the 45th consecutive game that Wimberly has caught a pass, the longest active streak in the nation.

“Coach told us it was going to be a 12-round boxing match and it was,” said Wimberly, who has TD receptions in four straight games. “The defense stepped up when we needed them to. It was great, fourth-quarter victory. Never could imagine I could have 15 receptions in a game. It’s crazy.”

Fajardo completed his first 12 pass attempts and capped a 96-yard scoring drive on Nevada’s second possession with a 5-yard TD pass to Wimberly for a 7-0 lead.

Roberts got loose on a keeper around the right for a 60-yard run to the 6, and Jon Lee scored from there on the next play for a 7-7 tie.

Fajardo threw his incompletion on the next series, was kicked in his bad right knee and left the game. Backup Tyler Stewart was intercepted on the next play at midfield by Christian Spears, who returned it 21 yards to the Nevada 22 before Anthony LaCoste opened the second quarter with an 8-yard TD run to put Air Force ahead 14-7.

Brent Zuzo’s 26-yard field goal made it 14-10, but Gagliano took a pitch left and raced 70 yards to the 2 to set up Hart’s 1-yard score for a 21-10 Air Force lead at 7:55.

But Fajardo, who returned in the second quarter, led Nevada on an 80-yard scoring drive capped by an 18-yard TD pass to Ricky Turner 2 minutes before the half to make it 21-17.

Roberts capped a 75-yard scoring drive to open the second half with a 9-yard TD run to give Air Force a 28-17 lead.

But Fajardo completed three passes to Wimberly for 36 yards on the next series then ran 19 yards on a naked bootleg around the left side to the end zone to cut the lead to 28-24 at 6:28 in the third quarter.

Hart rambled 27 yards to open the next series and Roberts carried six times for 40 yards on the drive, including an 11-yard TD run to put the Falcons up 35-24 with 1:41 left in the third.

Nevada answered with Don Jackson’s 9-yard TD run to cut it to 35-30 early in the fourth quarter. Wimberly caught a short pass in the flat on a 2-point try, but Justin DeCoud dragged him down just short of the goal line, setting the stage for the late drama.