Trevor Siemian threw a 15-yard pass to Tony Jones with 3:59 left in regulation to give the Wildcats a 31-28 lead and Gardner threw an interception on the next snap.
Northwestern couldn't pick up enough first downs to run out the clock in regulation and the Wolverines took advantage.
Gardner heaved a 53-yard pass to Roy Roundtree to set up Brendan Gibbons' 26-yard field goal with 2 seconds left to force OT.
The Wolverines (7-3, 5-1 Big Ten) barely prevented Northwestern (6-4, 4-2) from winning consecutive games in Ann Arbor for the first time since the 1934 and 1936 seasons.
The comeback victory keeps Michigan's hopes alive of winning a Big Ten title for the first time since 2004.
However, college football's winningest program needs another conference team to knock Nebraska out of first place in the Legends Division. The Cornhuskers would win a tiebreaker because of their win over the Wolverines two weeks ago when Denard Robinson left the game with nerve damage in his right elbow.
Gardner, making his second straight start in place of the injured Robinson, was 16 of 29 for 286 yards with touchdown passes to Fitzgerald Toussaint and Devin Funchess. Gardner ran for 47 yards and two scores.
Northwestern quarterback Kain Colter, who was taken out once because he wasn't throwing the ball well and another time because he was injured, was 8 of 14 for 96 yards and a TD. Colter ran 24 times for 82 yards and fumbled, setting up one of Michigan's scores in a closely contested game filled with ties and lead changes.
Siemian was 6 of 7 for 87 yards with two TDs, a game-tying 19-yard strike to Cameron Dickerson with 25 seconds left in the first half and the go-ahead pass to Jones late in the game.
Venric Mark had 104 yards rushing and a score for the Wildcats, who had a lot of success with option pitches to the outside only to stop calling that play frequently in the fourth quarter.
Toussaint ran for 92 yards and turned a short pass into a 28-yard, go-ahead TD late in the third quarter by breaking a tackle and sprinting down a sideline.
Northwestern seemed to set itself up for an upset victory at the Big House when it went ahead late in the game, picked off Gardner and converted a fourth-and-1 - by the nose of the football - on Colter's dive with 3:07 left on a play that stood after review.
But the Wildcats needed one more first down to run out the clock and couldn't earn another one against a suddenly stingy defense.
In overtime, on a fourth-and-2 from the Michigan 17, linebacker Kenny Demens stopped Tyris Jones on a run up the middle to allow the Wolverines to celebrate a thrilling victory.