Virginia center Jack Salt scored 12 points Wednesday, a career high. (Toni L. Sandys/The Washington Post)

On a night when its typically stifling pack-line defense turned out to be anything but, the fourth-ranked Virginia men’s basketball team received an unexpected scoring boost and made just enough plays down the stretch to outlast No. 24 Maryland, 76-71, on Wednesday at Xfinity Center.

Jack Salt scored a career-high 12 points, including a handful of dunks off teammates’ misses, helping Virginia (7-0) claim a fifth consecutive triumph in the ACC/Big Ten Challenge and sending the Terrapins to their first loss this season.

The redshirt senior had scored just 15 points in the five games he had played. Salt’s final field goal unfolded when he swooped in for a two-handed dunk off a missed shot, putting Virginia in front 68-60 with 1:54 left in front of an announced crowd of 17,950.

Maryland (6-1), meanwhile, handled the Cavaliers’ vaunted defense better than any other opponent Virginia had seen. No team had scored more than 59 points against Virginia in the first six games, but the Terrapins couldn’t overcome 14 turnovers that led to 16 points for the Cavaliers.

Virginia committed only two turnovers, both on offensive fouls.

The Terrapins, who got a team-high 15 points from guard Anthony Cowan Jr. before he fouled out in the final seconds, also shot 54 percent, by far the highest percentage Virginia has permitted.

“I thought we did a pretty good job considering the fact I think they shot over 50 percent from the field,” Salt said. “It’s not something that we want to do every game, but first true road test, and I think the guys did a pretty solid job.”

Virginia beat its second ranked opponent. It’s most recent game before Wednesday was a 53-46 victory over then-No. 25 Wisconsin in the final of the Battle 4 Atlantis tournament Friday in the Bahamas.

Trailing by 11 points Wednesday with a little more than six minutes left in the second half, Maryland staged a furious rally triggered by Aaron Wiggins’s three-pointer.

Coach Mark Turgeon called a timeout immediately after the basket, and the Terrapins got a dunk from center Bruno Fernando and Cowan’s layup to whittle the deficit to 61-57 with 4:04 to play.

After the teams traded baskets, guard Ty Jerome made a three-pointer from well beyond the arc to put the Cavaliers ahead 66-59 with 2:50 to go. Eric Ayala made 1 of 2 free throws for Maryland, and its margin shrank to 70-65 thanks to a layup and three-pointer by Cowan.

But Virginia hung on, making six of eight free throws in the final 37 seconds to beat its border state rival for the eight time in nine meetings, including the schools’ second in the ACC/Big Ten Challenge.

“Early on we ran good offense and made some shots,” Virginia Coach Tony Bennett said. “Defensively we were not solid in terms of blocking out. They were making plays, touching the paint, and then we made some subs, and the guys really stood in there. That’s why it’s so important, your depth.”

A 9-1 burst to begin the second half provided Virginia with its first double-digit lead of the game. Kyle Guy’s three-pointer got it started, and Salt added a two-handed dunk off a pass from Hunter and scored on tip-in to grow the margin to 48-31, prompting a timeout from Turgeon.

The Terrapins rallied quickly following the stoppage with three-pointers from Wiggins and Ayala, then clawed back further by driving aggressively to the rim and drawing fouls. Over roughly 90 seconds early in the second half, the Cavaliers committed five fouls.

When De’Andre Hunter picked up his third foul with 10:16 to play, Maryland was in the double bonus.

“We lost to a great team tonight that played at a high level,” Turgeon said. “Only two turnovers against us in this building. Shot a great percentage from three. They made a lot of tough shots. We lost some guys, but they made some tough shots. We’ll learn from this.”

The Terrapins, who went 10 for 16 from the foul line, were able to score in the painted area almost at will in the first half, with Fernando collecting baskets on putbacks and backing down smaller defenders.

“We shot 54 percent against a Virginia team that can flat-out guard you and outrebounded them by 10 or 11,” Turgeon said. “It was down to turnovers, really, and 50-50 balls in the first half.”

Maryland was plus-14 on points in the paint at halftime, but the Cavaliers still led 39-30 by hitting three-point shots and forcing turnovers that yielded open field goal attempts for Virginia’s stable of capable scorers, particularly Guy.

The junior guard scored 17 of his 18 points in the first half.

“We do a really good job of never worrying or wavering from our way, so there was never any panic or anything like that,” Guy said. “We just knew what we had to do to pull away a little bit more.”

Emily Giambalvo contributed to this report.