Adam Weber threw for a season-high 373 yards and a touchdown for Minnesota (1-3), which lost its third straight at home. The inconsistent Gophers hung with No. 20 USC for three quarters last week before losing 32-21, and lost 41-38 to South Dakota, an FCS team, two weeks ago.
Harnish and Flahive connected for a 2-yard score on fourth down early in the fourth quarter for a 27-16 Huskies lead.
Spann, whose previous high was 174 yards against Eastern Michigan last year, scored on a 61-yard run with 6:22 to play to clear out much of the crowd at TCF Bank Stadium. He had 106 rushing yards in the first half.
Harnish's first touchdown pass, a 10-yarder to Moore with 3 seconds left in the first half, gave Northern Illinois a 20-13 lead.
Duane Bennett had 74 rushing yards for Minnesota. He had 299 yards in the Gophers' first two games, but a sore ankle limited him to just six carries and 8 yards last week. Bennett's 55-yard touchdown run in the fourth quarter was negated by a holding penalty.
He was stuffed on a fourth-down play at the Northern Illinois 21 to end the same drive. Spann made the game-clinching rumble up the middle three plays later.
Weber found MarQueis Gray for a 29-yard touchdown for Minnesota with 4:18 to play, but the ensuing onside kick went out of bounds.
Both teams were looking for momentum heading into next week's conference openers -- Minnesota at home to Northwestern in the Big 10 and Northern Illinois at Akron in the Mid-American.
Minnesota may not be favored in any of its eight Big Ten games -- including five with ranked teams -- making it difficult to avoid a third losing season in coach Tim Brewster's four years. There were at least three "Fire Brewster" chants during the game.
It was the second straight strong performance against a Big Ten team for the Huskies, who lost 28-22 at Illinois last week, and are favored by many to win the MAC West Division.