Before guard Melo Trimble’s last-second 3-pointer downed Michigan State Saturday afternoon, the Maryland men’s basketball team’s offense endured a stagnant stretch.

The Terps’ previous bucket came at the 3:30 mark on Trimble’s jumper for a 60-58 lead. After Michigan State scored a layup to knot it moments later, Maryland missed its next three shots. Guard Anthony Cowan had a look from the free throw line with about a minute and a half left, but the team’s third-best foul shooter missed the front end of a one-and-one.

Those errant attempts didn’t hurt Maryland, however, because Michigan State failed to score in the final three minutes and 11 seconds. Trimble broke the Terps’ scoring drought with 1.1 seconds to play, ensuring his squad would tout a 63-60 win and enter the Big Ten tournament with two straight victories.

“[Nick] Ward and [Miles] Bridges are really good players, and we knew that they were going to make some shots,” forward Damonte Dodd said. “But every shot they took, we tried to make it tough, and I think that’s what we did. And down the stretch we got stops.”

Before the final three minutes, Maryland didn’t have an answer for the Spartans’ freshmen frontcourt duo, which combined for 40 points.

Bridges scored 11 points and five rebounds in the first half to help Michigan State enter intermission with a 28-27 lead. Ward overshadowed the 2016 McDonald’s All-American after the break, using his 6-foot-8, 250-pound frame to carve space inside. In 17 second-half minutes, Ward notched 18 points, grabbed 10 of his 16 boards and made six of his seven freebies.

Trimble said the Terps tried to defend the three-point line and keep the ball from Bridges after his 3-for-5 long-range shooting performance in the opening 20 minutes. But Michigan State relied more on ball screens in the second half, which Trimble said gave the Spartans open looks around the rim. Ward benefitted from the pick-and-roll action with several easy baskets.

“Our help-side [defense] just wasn’t good today,” Trimble said.

In the final moments, though, neither Michigan State big man could add to their scoring total.

After Cowan missed a deep 3-pointer with less than three minutes remaining, Bridges curled to the top of the key and launched a contested triple. The shot hit off the back iron. With Dodd boxing out Ward, Trimble corralled the rebound.

The Spartans’ next possession produced an open three-point look in transition, but guard Alvin Ellis III’s shot bounced off the rim and again into Trimble’s hands.

In the final 65 seconds, Ward had two opportunities to put Michigan State ahead. The first was a left-handed hook shot, but Dodd’s smothering defense forced Ward to leave his attempt short.

Then, Ward set a screen and rolled toward the rim with 11 seconds to play. Dodd and Cowan stayed with guard Cassius Winston, and forward Justin Jackson, who was in the lane, ran to guard Bridges on the perimeter. The defensive alignment left Ward alone in the paint.

Winston found the big man with a bounce pass, but Ward fumbled the ball out of bounds while rising for a shot. He hunched and interlocked his hands in disbelief. Guard Kevin Huerter, acknowledging Ward’s frustration, patted him a few times before walking down the floor.

Coach Tom Izzo replaced Ward during the ensuing timeout. Scoreless on four straight possessions, Michigan State had to rely on its defense in an attempt to force overtime.

“We defended it as well as we could,” Izzo said afterward, but he knew the effort didn’t prevent Trimble from sparking pandemonium in Xfinity Center.

“Miles had a wide-open shot, and he just missed it,” he said. “We had Alvin Ellis with a wide-open three, and of course the layup. I thought our execution was good. I couldn’t ask for anything more from my team except to make a few easier shots.”