LINCOLN, Neb. (AP) This time one went Nebraska's way.

Tommy Armstrong drove Nebraska 91 yards in the final minute, hitting Brandon Reilly with a 30-yard touchdown pass that survived a video review with 17 seconds left to hand sixth-ranked Michigan State a 39-38 loss that likely will ruin the Spartans' playoff hopes.

Armstrong rallied the Cornhuskers from 12 points down in the last 4 1/2 minutes. He scored on a short touchdown with 1:47 left to make it 38-33. After Michigan State (8-1, 4-1 Big Ten, No. 7 CFP) went three-and-out, he led the drive that defines his career so far.

More from FoxSports

Starting at his own 9, he hit Jordan Westerkamp for passes of 28 and 33 yards. Two plays later, he found Reilly for the winning score. Reilly went out of bounds and came back in to make the catch, but officials ruled it was legal because cornerback Jermaine Edmondson forced him out.

The Spartans got a final chance, but Connor Cook passed out of bounds from the Nebraska 41 as time ran out.

Nebraska's sideline cleared, a season full of pent-up frustration playing out with players and coaches at midfield dancing as the music blared. The Spartans walked slowly toward their locker room. The Huskers (4-6, 2-4) kept partying on the field.

The win came at the end of a tumultuous week that followed a 55-45 loss at Purdue that gave Nebraska its worst nine-game record since 1960. On Monday, athletic director Shawn Eichorst responded to fan angst by giving first-year coach Mike Riley a vote of confidence. Two days later, Nebraska chancellor Harvey Perlman voiced his support for Riley, who took over this year for Bo Pelini, who never won fewer than nine games in his seven seasons.

The first five of the hard-luck Huskers' six losses came by a total of 13 points, with the initial one against BYU coming by way of a Hail Mary.

The Huskers played strong throughout against the Spartans, but it didn't look as if it would be enough. Cook matched his career high with four touchdown passes and Michigan State used a drive that lasted almost 9 minutes of the fourth quarter to go up 12 points.

The Huskers weren't done.

Riley had a knack for upsetting top-10 opponents over his 14 years at Oregon State, and he said on Thursday that he thought the Huskers had a good chance to beat Michigan State. It was the first time an unranked Nebraska team beat a top-10 opponent at home since 1977.

Imani Cross ran 18 times for 98 yards, and Armstrong completed 19 of 33 passes for 320 yards. He ran for two touchdowns and passed for two.

Cook completed 22 of 35 passes for 318 yards and Holmes ran 20 times for 115 yards. His four TD passes gave him a school-record 68 for his career, two more than Kirk Cousins had from 2008-11.

The Spartans had not been overly sharp in their 8-0 start, and Nebraska put an end to their 12-game win streak in dramatic fashion.

--

Online:

AP college football website: www.collegefootball.ap.org