Marcus Coker carried the ball 32 times through several huge holes for 252 yards and two touchdowns, but the Hawkeyes (5-3, 2-2) missed a chance to move into a four-way tie for first place in the Legends Division with a rough November schedule ahead.
James Vandenberg went 16 for 24 for 177 yards and a touchdown to Marvin McNutt, who caught seven of those passes for 101 yards. Mike Meyer missed two field goals for Iowa in the first half.
Trailing 21-10, Gray sneaked for a first down on fourth-and-1 at the Minnesota 42 and hit a jumping Da'Jon McKnight for a 21-yard completion before Duane Bennett capped the drive with a 1-yard touchdown run with 8:22 left.
Then the Gophers caught Iowa playing almost 15 yards back on the kickoff, and Christyn Lewis recovered the onside attempt. Gray had a pair of sharp passes for first downs to move the ball forward and then, on fourth-and-goal at the 2, ran to his right to scrape the edge of the end zone with 2:48 remaining for Minnesota's first lead of the entire month.
Vandenberg was out of sync when Iowa got the ball back, and after three straight incompletions he escaped a sack but was well short of the first down on his scramble, giving the Gophers consecutive victories over Iowa for the first time since 1999 and 2000.
This was an all-around effort for first-year coach Jerry Kill's young team.
Minnesota was 118th out of 120 teams in the nation in sacks entering the game, but the Gophers took down Vandenberg three times - giving them eight for the season to match last year's paltry total.
Bennett had 20 carries for 101 yards and a touchdown despite a lost fumble, and Devin Crawford-Tufts caught two passes for 100 yards. Even the crowd played a part, despite Iowa backers filling at least one-third of the stadium. The fans were as into the action as they've been here since, well, last year's Iowa game.
They heartily cheered after a scoreless first quarter, a deserved ovation for a team that had been outscored 48-0 in the first quarter in its first seven games. The cumulative first-half score coming in for Minnesota was 103-3 in favor of the opponents.
The Hawkeyes lost three straight games to finish the regular season last year, ending with a 27-24 defeat here. Coach Kirk Ferentz was still miffed this week by his team's effort on that cold afternoon, when asked what he remembered from the game.
But this was more of the same. The Hawkeyes lost their fifth straight road game, and Vandenberg has yet to win away from Iowa in the regular season.
Meyer, who was named one of 20 semifinalists for the Lou Groza Award given to the nation's top kicker, missed from 24 and 43 yards on consecutive possessions, with the latter attempt bouncing off the left upright.
Gray found a wide-open Crawford-Tufts, a speedy freshman from the Minneapolis suburb of Edina, for 61 yards right after Vandenberg's touchdown toss to McNutt, the longest play from scrimmage this season for the Gophers.
Gray has struggled mightily with his accuracy in his first year as a starting quarterback, but this was by far his best game throwing the ball. He hit tight end Colin McGarry on third-and-goal from the 3 to tie it just before the half.
Kyle Henderson leveled Vandenberg on a blind-side cornerback blitz, knocking the ball out on third down at the Minnesota 14 for the first forced turnover by the Gophers in five games. Brandon Kirksey brought the fumble to midfield. Jordan Wettstein, subbing for the injured Chris Hawthorne, finished that drive with a 28-yarder on his first college field goal try.
But Coker passed the 250-yard mark on the next possession and powered past the goal line from the 1 to push Iowa's lead back to 21-10.