Whistle. Foul. Whistle. Foul. With his team down by 7 points and only 9:52 elapsed, Williams chased after Xavier forward Justin Martin while trying to stop a fast break, and heard the whistle again.

Williams stopped short, threw his head back in frustration, and headed to the bench. Trey Davis, averaging just 2.3 points per game, took Williams’s place.

It was unexpected — to everyone, apparently, except for Davis.

“Actually, before the game, I told [teammate] Tyler [Bergantino], it’s going to be a game for me. I could just tell in the first minute,” Davis said. “I said, ‘Tyler, I’m going to get in there and I’m going to do good,’ and then I went in. I just did what I know I could do.”

Davis responded by scoring 10 points in 13 first-half minutes to help the Minutemen claw back and enter halftime down only 35-34.

And with the starters back on the floor after intermission, UMass pulled ahead for good to notch a much-needed 77-72 win.

“He’s one of those players where I think his confidence is better than he actually is, which makes him better,” UMass coach Derek Kellogg said of Davis. “It’s a weird kind of way to talk about it, but for him to come in and not have played that much and do what he did . . . he proved now and he’s proved in a couple of other games he can help us win basketball games.”

In the first 10 minutes, the Minutemen (18-9, 8-6 Atlantic 10) were outmuscled and outmatched. Xavier (16-12, 8-6) dominated second chances, notching eight rebounds before UMass could manage one, and built the 7-point lead.

“I could just see the tempo of the game,” Davis said. “In the first minute, I was watching what Chaz was doing, and I saw when I got an open floor, I could knock my shot down. I told them, ‘Just look for me. If I kick it to you, get it back and I’m going to knock it down.’ ”

The Minutemen grabbed the lead on their first possession of the second half, and Terrell Vinson and Freddie Riley quickly found their shooting touches from behind the arc. The pair combined for just two 3-pointers in the first half, but hit 7 of 8 to start the second half. UMass went ahead, 53-51, with 13:12 on a transition 3-pointer by Vinson, and then built a 7-point lead.

“We play that way where we shoot a lot of threes and get up and down, and we were fortunate [Vinson and Riley] went on a run,” Kellogg said. “But the reality was, they were good shots and there weren’t that many that were forced.”

Xavier tried to fight back, led by guard Semaj Christon (17 points) and forward Isaiah Philmore (14), who each scored 11 in the second half. But the Minutemen’s success from long range helped them keep the game just out of reach for their second straight win.

Vinson, who set a school record with his 122d start, did it in style with a team-high 20 points. Riley added 18, and Davis chipped in 2 more in the second half to finish with 12. Williams finished with just 6 points in 21 minutes.

With the win, despite their top scorer being on the bench for extended periods, the Minutemen feel they have hit their stride at the right time.

“It just says we’re maturing, we’re trying to make sure we get out there and handle business, and take advantage of every opportunity,” Vinson said. “We needed the win bad to keep our tournament hopes alive. It’s just good to get the win and fight through adversity early.”