The Terrapins men’s basketball team had been in this position before. They were trailing in the second half at home with the crowd trying to will them back into contention.

Many of their 27 straight wins at Xfinity Center had come without hiccups. But when the Terps needed to rally in others, they did.

Saturday, though, Wisconsin withstood every punch the Terps threw. The Badgers staggered but never fell. Every time coach Mark Turgeon’s team made a run, Wisconsin would respond with a long-range jumper, deflating the No. 2 Terps and silencing the sellout crowd in a 70-57 win. It marked the Terps’ first home loss in about 14 months.

“It felt like they always hit the big shot,” forward Jake Layman said. “You got to give them credit. They came to play tonight. They hit big shots when they needed to.”

The Terps found themselves in need of a rally because Wisconsin ended the first half on a 29-7 run to take a 15-point lead into the locker room. It was the largest halftime deficit the Terps had faced all season.

Still, the Terps came out of the break immediately chipping away at the Badgers’ lead. Guard Melo Trimble, who went 1-for-14, hit his only field goal with 17:48 left to trim the deficit to single digits for the first time since Trimble’s free throws with 5:10 left in the first half.

While Wisconsin appeared to be on its heels for the first time since the early portions of the night, forward Nigel Hayes responded with a 3-pointer to push the Badgers lead back out to 12.

“We knew they were going to come out with pressure and we fell into the trap of playing not to lose instead of taking that lead and trying to double it to 30,” Hayes said. “Luckily, we were able to catch ourselves. Guys made plays.”

Hayes’ long ball was the start of a trend that persisted throughout the second half. After the Terps cut the deficit to seven with 13:01 left, Wisconsin forward Vitto Brown buried a 3-pointer on the ensuing possession.

The Terps continued to try to claw back, trimming the gap to six points on center Diamond Stone’s dunk with 10:48 remaining.

For a few minutes, Xfinity Center was deafening. It was the type of moment that had swayed the tide so many times over the past two seasons in College Park.

Wisconsin refused to be the Terps’ 28th victim.

Guard Bronson Koenig drilled a long ball about two minutes after Stone’s dunk to push the Badgers’ edge to 10.

“It was tough, man,” guard Rasheed Sulaimon said. “Every time we felt like we were making a big run or chipping away at the lead … they made a big shot and that can really be discouraging at times.”

The Terps would get the deficit to eight twice after Koenig’s shot. Both times Wisconsin hit a 3-pointer, sending a steady stream of Terps fans for the exits.

Earlier in the half, Wisconsin coach Greg Gard said he made a decision to let his team fight through the Terps’ jabs on its own rather than take timeouts.

“I decided before the 16-minute media [timeout], I want to see if this group is going to grow up out here on the floor,” Gard said.

They did. The Terps suffered the consequences.