LINCOLN, Neb. (AP) -- Sam Keller did his job. Then all he could do was watch as his teammates on defense were trying to do theirs.
What Keller saw was frightening. Ball State had two opportunities to take the lead in the final 22 seconds -- one when an almost sure TD pass was dropped; the other when a long field goal was wide.
In the end, Keller's third touchdown pass stood as the winning points as No. 24 Nebraska defeated Ball State 41-40 and avoided what arguably would have been the most embarrassing defeat in school history.
"I just had to have faith in the defense," said Keller, who passed for a school record 438 yards. "And I was saying a prayer or two."
If it was two prayers, both were answered.
After Keller gave the Cornhuskers the lead with 3:13 to play, Ball State started at its own 22.
Nate Davis completed six passes and converted a third down with a 3-yard run to give the Cardinals a first down on the Nebraska 38.
The next sequence had Keller, and everyone with ties to Nebraska, holding their breath.
On second down, Dante Love, running open on a post pattern, had what appeared to be a perfect throw and easy touchdown bounce off his hands at the 10.
Then, after linebacker Steve Octavien broke up a pass on third down, Ball State's Jake Hogue lined up for a 55-yard field goal attempt with 17 seconds remaining. Hogue, who hit earlier from 45 and 22 yards, hooked his kick wide left.
"We're very disappointed in the outcome," Ball State coach Brady Hoke said. "It's a tough pill to swallow because we had opportunities."
More opportunities than Nebraska cares to recount.
The Cardinals' moved almost effortlessly against the Huskers all afternoon, as they rolled up 610 yards of offense, the most by a Nebraska opponent since Washington amassed 618 in 1991.
Behind Davis, who passed for 422 yards and three touchdowns, 23-point underdog Ball State scored on four of its first six possessions of the second half to lead 37-28 early in the fourth quarter.
Nebraska fans, already were wringing their hands over an uninspired performance in last week's loss at home to top-ranked Southern California, let their feelings be known.
Boos came pouring out of the Memorial Stadium stands as the Cornhuskers allowed 40 or more points for the second straight week, the first time that's happened since the end of the 1990 season.
"They had a right to boo us," said Maurice Purify, who caught the 11-yard pass from Keller that put Nebraska ahead for good. "We weren't playing as good as we should have played. We were close to losing the game."
Nebraska pulled within 37-35, with 9:21 left, when linebacker Bo Ruud intercepted a pass that bounced off his chest into his hands and returned it 34 yards for a touchdown.
"They threw a little floater," Ruud said. "I bobbled it, and I took off."
Davis said Ruud's interception was the game-changing play.
"Dumb decision on my part," the Ball State quarterback said. "I should have thrown it away, but you learn from your mistakes."
Keller, who completed 29 of 37 passes, was at his best on the winning drive. He dinked the Ball State defense with short passes to running back Marlon Lucky and hit Sean Hill for a 32-yard gain, before finding Purify for the score. Nebraska went for the 2-point conversion, but Keller's pass to Todd Peterson was out the back of the end zone.
The Cardinals, who nearly upset a second-ranked Michigan team a year ago, played on even terms with the Huskers.
Because they couldn't finish the job -- again -- coach Bill Callahan didn't have to explain a loss the likes of which has never been seen in Lincoln in the program's 118-year history.
It might not have matched Appalachian State's upset of Michigan in national magnitude, but it would have been a low point for a coach who already is owner of the most lopsided loss in program history (70-10 at Texas Tech in 2004).
"It's a step forward because it's a win," Callahan said. "These wins are hard to come by in this day and age because of the way people are playing football. We see that across the country. You would always want things to go a little bit better, and it didn't, so you have to deal with that for the duration of the game. Our ability to stay in the game, to keep rallying, was outstanding."
Trailing 14-10 at the half, Ball State covered 39 yards in three plays after Quentin Castille fumbled early in the third quarter, with Davis scoring the go-ahead touchdown on a 14-yard run.
Nebraska answered with Keller's 73-yard TD pass to Sean Hill, but Ball State came right back with Lewis running untouched for 43 yards.
Keller's 18-yard TD pass to Nate Swift put Nebraska back on top, but Ball State went up 31-28 on Davis' 58-yard pass to Love.
B.J. Hill intercepted Keller near the goal line, and then Davis finished a five-play, 96-yard march with a 21-yard pass to Madaris Grant, putting the Cards up 37-28.
"There are all types of wins," Callahan said. "I'm just proud of the fact our kids found a way to get this one done today."