It wasn’t pretty, but Michigan will take it.

The No. 5-seeded Wolverines were able to overcome a sloppy first half and hold off a late run to beat No. 12-seeded Iowa, 77-71, in overtime at Madison Square Garden Thursday.

The Hawkeyes (14-19) nearly pulled off the upset, trailing Michigan 74-71 with 24 seconds to go, but forward Luke Garza missed a potential game-tying three. Wolverines center Jon Teske then kept Iowa’s upset bid alive, going 0-for-2 at the line, but the Hawkeyes again failed to score on the ensuing possession, and Michigan forward Duncan Robinson made both free throws and Corey Matthews added another to close out the game.

Michigan (25-7) will now face No. 4-seeded Nebraska in the third round of the Big Ten Tournament.

Rutgers tops Minnesota in first round of Big Ten Tournament

Michigan trailed 40-35 at the half in large part due to a cold shooting performance that saw the Wolverines go 0-for-7 from behind the arc. The Wolverines didn’t score their first three-pointer until 9:32 left in regulation.

Michigan, however, was able to overcome their poor three-point shooting and quickly went on an 11-0 run in the opening three minutes of the second half to take a 46-40 lead.

Iowa, however, came back and was able to send the game into overtime on Jordan Bohannon’s three-pointer with 16 seconds to go but ultimately couldn’t complete the upset bid.

The Wolverines were able to pull out the win despite having to play the majority of the game without star big man Moe Wagner, who saw just 15 minutes of action before fouling out. Wagner finished with 11 points and three rebounds.

Iowa PG misses free throw to preserve fallen player’s record

Duncan Robinson scored all three of Michigan’s three-pointers, including a clutch trey to put the Wolverines up 72-70 with 2:22 to go in overtime.

Matthews, Michigan’ second-leading scorer, led the Wolverines with 16 points.