Terrapins men’s basketball coach Mark Turgeon wasn’t pleased.

His star guard, Melo Trimble, had just settled for a fadeaway 3-pointer with the Terps deadlocked at 48 and seconds remaining in regulation Tuesday. The shot fell short.

So when Trimble walked off the court with the game headed into a five-minute period, Turgeon was in the sophomore’s ear. He wanted Trimble to attack the basket. The Big Ten preseason Player of the Year responded.

On the Terps’ first possession in overtime, Trimble slashed into the lane for a three-point play. Later when Trimble worked his way into the paint and defenders converged on him, he simply found his teammates for layups.

Trimble’s aggressive mindset in the extra frame helped the Terps avoid their first home defeat since Dec. 3, 2014 as they eked out a 62-56 overtime victory against Northwestern at Xfinity Center. Trimble had a game-high 18 points and six assists, including three points in overtime and the assist on the go-ahead basket. Behind Trimble’s performance and solid defense, the Terps overcame 16 turnovers and a season-low point total.

“All night we settled for jump shots,” Turgeon said. “In overtime, [Trimble] didn’t settle. He drove. He got to the rim.”

When Trimble swiped the ball way from Northwestern center Joey van Zegeren with 28 seconds remaining, he said he didn’t expect Turgeon to call a timeout. But the fifth-year coach, who has previously said his mentors tell him not to call timeouts in late-game situations, surprised Trimble.

“It took the momentum away from me,” Trimble said. “I knew again I was taking a three and this time it just didn’t go in. But I knew what I was going to do before he called the timeout. I just wish he didn’t.”

Trimble admitted his shot selection was affected by the game-winning 3-pointer he hit with seconds remaining in a 63-60 win over Wisconsin on Jan. 9.

But the Terps (17-2, 6-1 Big Ten) were in that position because of a stagnant offense. Four days after reaching the century mark against Ohio State in a 100-65 victory, the Terps struggled against Northwestern’s (15-5, 3-4) matchup zone played for much of the night. They didn’t score a point in the final 4:43 minutes of regulation.

“When you play Maryland, you’re not going to win a racehorse game with them,” Northwestern coach Chris Collins said. “We had to try and manage the possessions and make it a grind-it-out game, and I thought we did that.”

The Terps offense came alive in overtime thanks to Trimble’s slashing drives. With about a minute remaining, Trimble hit freshman center Diamond Stone, who was cutting to the basket, for a three-point play. Trimble’s second, and final assist of overtime, gave the Terps the lead for good.

While Trimble went 8-for-18 from the field, including 1-for-6 on 3- pointers, he was the Terps’ star Tuesday.

“In the first half, he was being a little soft against the zone,” senior forward Jake Layman said. “But I think as the second half went on, and in overtime, he realized that for him to be effective, he had to get to the rim. And he did that.”

Stone helped with five of the Terps’ last seven points and was second on the team with 11 points despite being plagued by foul trouble. He finished with 15 minutes.

Part of the reason the game went into overtime was the Terps’ woes on the defensive glass. They allowed 16 offensive rebounds, which the Wildcats turned into 16 points.

But when the Terps needed a defensive rebound up four with 16 seconds remaining in overtime up four, Terps forward Robert Carter Jr. secured the last of his game-high 14 rebounds. His two free throws moments later were the final touches in the win.

On a night the Terps struggled and their best player missed a potential game-winning shot, they found a way to secure a victory. Turgeon was frustrated at times, but he couldn’t fault his team’s fight.

“Some nights things don’t go well and you just have to figure out ways to win,” Turgeon said. “And we did that.”