When Wisconsin’s star forward Ethan Happ earned his fourth foul of the game and second in 10 seconds Monday, the Xfinity Center crowd roared as loudly as it had all night.

The Maryland men’s basketball team had dominated Happ and his Badgers to that point, and with a 16-point advantage and Wisconsin’s biggest offensive threat on the bench for the foreseeable future, the Terps seemed to be well on their way to their most comfortable Big Ten win of the season.

But Happ’s replacement, Nate Reuvers, quickly went on an 8-0 personal run that sparked a furious comeback from Wisconsin, culminating in a Reuvers 3-pointer to tie the game with about three minutes left and another triple from guard Brad Davison to take the lead a minute later.

The Terps led by as many as 21 on Monday, but a disastrous stretch midway through the second half meant they needed more late heroics from guard Anthony Cowan to gut out a 64-60 victory and extend their winning streak to six.

“We were terrific defensively for … I don’t know, 25, 28 minutes,” Turgeon said. “And then Wisconsin turned it on. Man, were they good in the second half.”

No. 19 Maryland (15-3, 6-1 Big Ten) had struggled with slow starts in its past few games but had no such problems Monday. Coach Mark Turgeon’s team started 7-for-11 from the field and made four of its first five 3-pointers to open a 20-10 lead over the Badgers.

For the first 20 minutes, Wisconsin (11-6, 3-3) couldn’t find any open looks against Maryland’s defense, and other than a couple of jumpers from Davison early, it couldn’t knock down the contested ones it created.

Happ, who came in averaging 20.6 points, had six before halftime and finished with 11, struggling to score against forwards Bruno Fernando and Jalen Smith. But the Terps cooled off toward the end of the half and didn’t score for the final four minutes, so even with the Badgers scoring just five points in the final 14, Turgeon was unhappy with the end of the period.

“Our defense was off-the-charts good, and [the lead at halftime] was 18. I thought it should’ve been 25,” Turgeon said. “We were a little bit stagnant. We never really got going.”

The sluggishness on offense continued after halftime. After guard Eric Ayala hit a three to extend the edge to 38-17 less than three minutes into the second period, the Terps made just three field goals — all from Cowan — the rest of the way, their offense built largely on a 24-for-29 performance from the foul line. Fernando, who put up eight points on five shots in the first half, got into foul trouble and had just two after the break.

“We play a lot through Bruno,” Turgeon said. “We didn’t have him.”

Shortly after Happ picked up his fourth foul, Fernando also earned his fourth, and Turgeon sent him to the bench. With the lead still at 15, however, the game didn’t seem in question.

But then Reuvers and Wisconsin caught fire, and Maryland was in trouble. After missing their first 10 three-point attempts, the Badgers made 11 of their next 17. Their final make was Davison’s corner effort to put his team up 60-59 with 2:01 to play, Wisconsin’s first lead since the 17:25 mark of the first half.

“I don’t think we had the same intensity,” guard Darryl Morsell said. “[And] they were hitting a lot of big shots. In the first half, they went 0-for-8 from 3. In the second half, I don’t know what they shot, but they were hitting everything.”

After a couple of empty possessions, Cowan found himself with the ball far beyond the three-point line deep in the shot clock, as he has countless times before. Again, he came up huge for the Terps, with a triple to give them a 62-60 edge.

“My coaches had confidence in me, my teammates did as well, so I was confident in myself,” said Cowan, who finished with a game-high 21 points. “I saw the defender sagging off a little bit, so I just pulled up.”

Wisconsin called timeout trailing by three with 11 seconds left, and Reuvers set a screen for guard D’Mitrik Trice out of the break. After the barrage of 3-pointers in the previous 15 minutes, the Terps had emphasized switching off screens to guard shooters. But forward Ricky Lindo followed Trice, leaving Reuvers on the three-point line and no Terp within 15 feet of him.

Reuvers was sitting on 18 second-half points and a 4-for-7 mark from long range, but his most open look of the night rimmed out, and his near-singlehanded effort to steal a victory came up short.

“We made a mistake again late defensively … and gave the kid a wide-open shot,” Turgeon said. “The building was so loud, I think it really helped us. It’s a good win for us.”