Dez Wells had scored four straight points and already had 24 on the game, so Wisconsin forward Sam Dekker made sure to sprint out to defend the Terrapins men’s basketball guard on the left wing late in the second half Tuesday night at Xfinity Center.

Only Wells seemed to expect that. So the senior jab-stepped to his right to draw Dekker off balance, then exploded toward the rim and took flight about a step outside the paint with about four minutes left in the contest.

When he landed, the announced 17,950 gold-clad fans erupted.

Wells had thrown down a thunderous dunk after blowing by Dekker, one that adds to a long list of career highlights and helped propel the No. 14 Terps to a 59-53 win over No. 5 Wisconsin before a sold-out crowd in the program’s first top-15 home matchup since 2003.

Wells, the vocal leader on a team rife with youth, finished with 26 points to lead the Terps (23-5, 11-4 Big Ten) in their first win over a top-10 opponent during this resurgent season. He also had seven rebounds, four assists and a string of six points late in the game that proved key in the thrilling victory.

“Boy, it’s a good feeling when you look out there, and you see your senior leader say, ‘All right coach, I got this. There’s no way we’re not going to win this game,’” coach Mark Turgeon said.

And Wells’ performance came against Wisconsin (25-3, 13-2), a team that reached the Final Four last season. The Terps now not only figure to make their first NCAA tournament since 2010 but also are in a position to earn a top-4 seed.

Fans, some of whom had been lined up outside Xfinity since Monday night, stormed the court while Wells and the Terps trotted off to the locker room.

“The crowd was amazing for us,” Wells said. “They’ve seen us through some tough times, and for them to be part of a season like this is well worth it. We just want to give those guys their money’s worth and something to talk about.”

Freshman point guard Melo Trimble also made significant plays down the stretch in the win over the Badgers. The shifty rookie had 16 points, and his late layup pushed the Terps’ lead to five with 33.3 seconds left. Wisconsin never seriously challenged after that.

Trimble and Wells ensured the offense ran smoothly all game as the Terps had just six turnovers and shot 48 percent from the field.

“[Dez] was terrific,” Turgeon said. “And Melo was Melo. He made big plays down the stretch.”

Wells and Trimble weren’t the only Terps to contribute to a victory against the Big Ten’s first-place team. After Wisconsin forward Frank Kaminsky, a national Player of the Year candidate, scored four points in the first four minutes, lightly used freshman forward Michal Cekovsky checked in the game.

Kaminsky didn’t score for the next six minutes as Cekovsky used his length to disrupt the Badgers’ star senior. Cekovsky even added a powerful dunk that played its part in a 14-4 run midway through the half that helped the Terps take control of the game.

“He stayed focused and stayed ready,” Trimble said. “When his name was called, he got in and produced.”

Wisconsin made a run out of the break to tighten up the game. Behind Kaminsky, who finished with 18 points, the Badgers opened the second half with a 13-4 spurt, and the game moved forward as a neck-and-neck affair.

“We knew they were going to make a run,” Wells said. “So I told my guys, ‘They got their first swing in. So are we going to take a step back or are we going to swing back and show toughness and poise and finish the game?’”

Wells, as he often has been in his Terps career, was the one to keep the team afloat.

He scored four straight points on a pair of short jumpers midway through the second half to give the Terps a 45-41 lead. Then with the score tied at 47, Wells scored the Terps’ next six points. The last two came on his roar-inducing slam and gave the team a five-point cushion.

From there, the Terps hung on for the win — their eighth in eight games decided by fewer than seven points — that added another memorable night to Wells’ experiences and another key victory for a team that’s back in the national limelight after an extended absence.

“I knew we were a great basketball team,” Trimble said. “One game’s not going to change what everybody thinks. They’re still going to think we shouldn’t have beat Wisconsin, but I think we’re reaching that peak, keep getting better and showing people we’re the real deal.”