Rasheed Sulaimon embraces Jaylen Brantley after Maryland held on to beat Michigan at Xfinity Center. (Toni L. Sandys/The Washington Post)

Maryland Coach Mark Turgeon set one rule before Sunday’s 86-82 win over Michigan. Everyone on his team had to smile more. He didn’t live up to his end of the demand. Few things make Turgeon unhappier than turnovers and blown defensive assignments, and the Terrapins had plenty of both against the Wolverines.

He did make one exception, though, and it came during the most pivotal stretch of the game. With Maryland clinging to a two-point lead with just under seven minutes remaining, senior forward Jake Layman came up with a rebound under his own basket. As he turned to make an outlet pass, Michigan’s Muhammad-Ali Abdur-Rahkman picked the ball off and dropped in a layup to tie the game. Nobody was laughing but Turgeon.

Even he could find humor in the most stressful of times Sunday, when Maryland’s players returned to being themselves after a two-game losing streak. This was far from a work of art — the Terrapins blew a 16-point first-half lead, committed 18 turnovers and gave up 12 offensive rebounds — but it was the most free Maryland has played in weeks. It was a liberating performance underscored by balanced scoring and defensive tenacity. After Turgeon was done chuckling about Layman’s mistake, the Terrapins pulled back ahead in the final minutes and held Michigan to 2-for-8 shooting over its final possessions to seal the win.

“We didn’t put any pressure on ourselves,” said Layman, who finished with 16 points on 5-for-6 shooting.

Turgeon opted to keep a big lineup against the run-and-gun Wolverines, who upset Maryland in Ann Arbor, Mich., in January and proved again to be a matchup nightmare Sunday. While the Wolverines keyed on sophomore point guard Melo Trimble (14 points on 3-for-10 shooting), Maryland’s big men went to work.

Robert Carter Jr. finished with 17 points, while freshman center Diamond Stone added 13 points and five rebounds in his return after being suspended for Thursday night’s loss at Minnesota. Maryland (23-5, 11-4 Big Ten) also received a boost from junior center Damonte Dodd, who finished with seven points, six rebounds and two blocks.

Maryland, which had a combined eight bench points in its previous three conference games, received 18 from its reserves Sunday. Maryland looked agitated to start, clearly motivated by the events of the past week. It lost by 13 to Wisconsin just eight days earlier at Xfinity Center — ending a 27-game home winning streak — and was further embarrassed after losing to Minnesota on Thursday night.

“I haven’t eat a lot of food since that game,” Turgeon said. “I can’t wait to eat.”

Sunday’s performance began with a burst from Trimble, whose acrobatic finish in the lane in the opening minutes preceded a 16-1 run. Maryland led by 16 with less than eight minutes to play in the first half, but Michigan closed the half by hitting seven of its final 11 shots to trim the Terrapins’ lead to 41-36 at halftime.

As Mark Donnal (25 points) scored 12 points within the first five minutes of the second half to give Michigan a one-point lead, Trimble helped restore order. Trimble had entered the game mired in the worst slump of this career, hitting just 7 of 38 from the field over the past four games, but he played more freely Sunday. He hit a three-pointer to interrupt Michigan’s surge, and he later weaved his way into the lane for another layup to give Maryland a 57-56 lead with 13 minutes 44 seconds left. Layman added two three-pointers over the next 93 seconds to help Maryland take an eight-point lead. It was far from safe, and at times Michigan looked as if it would hand the Terrapins a third straight loss.

“Were we desperate? I don’t think so. But we were dialed in,” Turgeon said.

After Michigan’s Zak Irvin cut Maryland’s lead to 80-78 with 2:47 remaining, Carter finished off a Layman miss with another tip-in to push the lead back to four. Michigan had a chance to tie in the final 30 seconds after Trimble missed a shot in the lane. But Wolverines guard Derrick Walton Jr. was called for an offensive foul on Maryland guard Rasheed Sulaimon with 18 seconds remaining.

“We have a lot of confidence in each other,” Carter said. “We are a happy team. We come out and enjoy the game and play for each other.”

Trimble could finally smile after it was all over. He wasn’t perfect Sunday — he had seven turnovers — but he didn’t need to be. He finished with eight rebounds and went 7 for 8 from the free throw line, which was crucial. Maryland is 20-2 over the last two seasons when Trimble makes seven or more trips to the line.

Before he could even fully untuck his jersey, he was rushed by several teammates. They knew how difficult this week had been on the sophomore star, so they hugged Trimble and tapped his head after watching him help pull the Terrapins out of their worst lull of the season.