Illinois (4-4, 1/3 Big Ten) trailed 24-21 with 6:33 left in the game when linebacker T.J. Neal stripped the ball from running back David Cobb. Cornerback V'Angelo Bentley grabbed the ball at the Gopher 12 and ran it in for a touchdown.
Illinois then held the Gophers (6-2, 3-1) four times at the Illini 26 with less than two minutes to play.
After the final whistle, Illinois' players streamed off the sideline, gathering in front of the band for several minutes of celebration.
The win ended a three-game losing streak for the Illini and gave them just their second conference win in coach Tim Beckman's two and a half season in Champaign.
Much of the credit belonged to the defense.
The Illini came into the game giving up 484.6 yards and 35.9 points a game.
Cobb finished with 118 yards and two touchdowns on 22 carries. But Illinois held him in check for almost three quarters, with 34 yards on his first 16 carries.
The loss ended a four-game win streak for the Gophers and robbed them of what would have been their first 4-0 Big Ten start since 1967.
Illinois led 14-0 in the first quarter, scoring on two of its first three drives. Most of the yardage and one of the scores coming from quarterback Reilly O'Toole.
The senior backup started for Wes Lunt, who is out with a broken leg, and finished 14-21 for 188 yards and a touchdown. He added another 59 yards on 17 carries and a rushing touchdown.
O'Toole threw for the first touchdown, hitting tight end Jon Davis from 3 yards with 9:31 left in the first quarter. Just under seven minutes later, O'Toole ran the ball in from 9 yards.
But at least as important was the start by Illinois' defense.
The Illini forced the Gophers off the field without a first down on Minnesota's first two drives, the first time Illinois has done that to an opponent since 2012.
Between quarterback Mitch Leidner and Cobb, the Gophers came to life in the third quarter. They put up 21 points on a 52-yard Leidner strike to Isaac Fruechte and a pair of rushing touchdowns by Cobb, from 1 and 13 yards.
Those 21 unanswered points gave Minnesota its first and only lead, 24-21.