Forty minutes before playing Ohio State on Saturday, the Maryland men’s basketball team huddled on the Xfinity Center court and danced as Migos’ Bad and Boujee blared over the speakers.

Players continued to dance to the music when they returned for shootaround about 10 minutes later, and they smiled while engaging in personalized handshakes with director of basketball performance Kyle Tarp before tip-off. Four of Maryland’s starters flashed grins when their names were called during lineup introductions.

Despite losing consecutive contests for the first time this season entering Saturday, the Terps remained loose, remembering their accomplishments this season that included the team’s best start in program history.

The fun didn’t stop when the game started, as the Terps smiled, cheered and gave out chest bumps as they opened a 45-31 halftime lead. Even as Ohio State tried to crash No. 21 Maryland’s party in the second half, the Terps remained poised to close out an 86-77 victory at Xfinity Center, snapping their two-game losing streak.

“What a great day,” coach Mark Turgeon said. “Our guys were dialed in the whole game.”

Freshmen guards Anthony Cowan and Kevin Huerter led the Terps with 19 and 18 points, respectively. Forwards Marc Loving and Jae’Sean Tate, who combined for 38 points in Maryland’s 77-71 win over Ohio State on Jan. 31, again led the Buckeyes with a combined 44.

Maryland (21-4, 9-3 Big Ten) jumped out to a 9-0 start after Ohio State, playing without its third-leading scorer, guard Jaquan Lyle, started 0-for-9 from the floor. The Buckeyes (15-11, 5-8) chipped into the Terps’ lead, but Maryland’s bench, which has been inconsistent this season, helped the Terps pull away entering intermission.

In the opening period, Maryland’s reserves outscored Ohio State’s, 20-0. Guard Jaylen Brantley, who had shot 2-for-11 in his previous four outings, led the group by scoring eight of his 11 points in the half. Then forward Michal Cekovsky slammed two dunks with about four minutes left in the frame, igniting the 17,950 fans at Xfinity Center and causing multiple players to chest bump as the Buckeyes called a timeout.

“Coach Turgeon always talks about how he likes the depth on our team,” Cowan said. “Jaylen really came in and turned the game around in terms of getting some good points and getting a lot of energy.”

The Terps, who shot a season-low 33.9 percent from the field in their 70-64 loss at Penn State on Tuesday, shot 43.8 percent from beyond the arc and 55.2 percent overall in the first half Saturday.

Ohio State cut Maryland’s lead to six behind Loving and Tate’s 29 combined points in the second frame, but the Terps responded by scoring on three straight possessions, which forward L.G. Gill capped with an and-one layup to send the sellout crowd into a frenzy.

After the under-12 media timeout, Cowan scored seven straight points to regain Maryland’s double-digit edge.

Cowan had missed his past 11 shots from beyond the arc entering Saturday, but he said making his first attempt against the Buckeyes raised his confidence. The rookie’s contributions were crucial on a day guard Melo Trimble, who entered the contest with the fifth most points per game in the Big Ten (16.9), notched 10 points.

Ten Terps scored on 19 assists, while the bench outscored the Buckeyes’, 33-0.

“I told our guys, the things that Maryland would have to do to beat us, they did,” Ohio State coach Thad Matta said. “They made some great plays.”

With about two minutes remaining and Maryland clinging to a five-point lead, Huerter drained a 3-pointer. A wide grin emerged on his face as he backpedaled down the court.

On the next possession, Cowan, who usually doesn’t express emotion on the court, made his third 3-pointer of the contest, flashing a smile toward Maryland’s bench and holding his follow through in the air. The Terps were back to winning close games, and they were soaking in their largest victory since Jan. 24.

Even Matta couldn’t help but envy the Terps’ elegance, flashing a smile at Huerter in the postgame handshakes.

“It was a really cool moment,” Huerter said. “Tate was kind of smiling after I made it too. Sometimes games come down to who makes shots at the end of the game. The shots were falling today.”