Mark Turgeon was hungry. The Terrapins men’s basketball coach said he’d barely eaten since Thursday’s loss to lowly Minnesota. It showed.

Less than seven minutes into Sunday’s game, he’d ripped off his suit coat. During his postgame press conference Sunday, he had to stop midway through to request a bottle of water. It had been a grueling few days for the fifth-year coach and his team, which had lost two straight after climbing to No. 2 in the rankings.

“I was as down as you can be,” Turgeon said.

Saturday, he’d refused to call the matchup with Michigan a must-win. But the No. 6 Terps seemed to play with desperation Sunday. Even after blowing a 16-point lead, they made the necessary plays down the stretch to hold off Michigan, 86-82, before a sellout crowd at Xfinity Center.

“That was a heck of a college basketball game,” Turgeon said. “Guys just making plays, making plays, making plays.”

Michigan took a three-point lead on a layup from Wolverines forward Mark Donnal, who finished with a game-high 25 points on 10-for-13 shooting, with 5:47 left. The tension in Xfinity Center heightened as the Terps were minutes away from their first three-game losing streak since 2012.

But they responded with eight straight points. Then, clinging to a three-point lead with less than 30 seconds left, guard Rasheed Sulaimon drew an offensive charge. He hit two free throws at the other end to help seal the win.

Michigan drilled a 3-pointer with 6.9 seconds left to trim its deficit to two, but Terps guard Melo Trimble sunk two more free throws at the other end. And then guard Jaylen Brantley, who had lost his spot in the rotation just weeks ago, notched a steal on the inbounds pass to end the game.

Sulaimon sprinted to Brantley for a hug, while forward Damonte Dodd re-enacted Drake’s “Hotline Bling” dance. It marked relief, finally, for a team that had gone 12 days without a win.

Turgeon received production from everyone he sent on the court, with all eight players who saw action scoring at least five points. Forward Robert Carter Jr. led the balanced attack with 17 points on 8-for-13 shooting.

“We got a bunch of confidence in each other,” Carter said. “We felt like we were going to get out of it sooner or later.”

The Terps jumped out to a commanding lead in the first half with a tenacious defensive stretch. After Trimble was whistled for a charge and Turgeon ditched his coat, the Terps rattled off a 14-0 run while forcing Michigan to miss eight straight shots. The Wolverines went on to miss five more consecutive shots from the field after that stretch.

“Coach is great,” Layman said. “He didn’t kill us or anything like that. He wanted us to just get back to having fun. Kind of bringing ourselves up there. Tonight, at times, we showed that. Too many turnovers here and there, but I think we definitely showed — that spurt in the first half — we are a good team.”

The lead wouldn’t last, though. Donnal and the rest of the Wolverines squad caught fire from the floor, especially from beyond the arc, where they finished 13-for-27.

Less than four minutes into the second half, the Terps’ 16-point lead was gone. But they never seemed too worried. Trimble, whose struggles continued with a 3-for-10 shooting performance and seven turnovers, flashed his smile throughout the afternoon.

Smiling. It was something Turgeon said he put an emphasis on entering Sunday’s matchup. He wanted his team to play freely again. He conceded he didn’t follow his own advice, smiling just once during the game after Layman passed the ball back to Michigan after a rebound, leading to a Wolverines and-1.

But when the nail-biter finally ended and the Terps’ losing streak was over, Turgeon could catch his breath. And soon, eat.

“My stomach is up here growling,” Turgeon said.