KINGSTON, R.I. — For a moment it looked like UMass had created a miracle comeback when Luwane Pipkins’ would-be game-tying 3-pointer from the right corner rolled around the inside of the rim with 13 seconds left.

The Ryan Center crowd held its breath before erupting when the shot slipped out of the basket and into the hands of Jared Terrell.

“It looked like it was good,” UMass coach Derek Kellogg said. “Sometimes the basketball gods don’t give it to you.”

Rhode Island held on to edge UMass 79-77.

The URI lead, which looked safe at 10 points with a 1 minute, 14 seconds left in the game, had all but disappeared thanks to missed Ram free throws and DeJon Jarreau’s personal comeback push for UMass.

The freshman scored 13 of his 15 in the second half and seven of those in the last 68 seconds. He added a career-high nine assists.

After Pipkins’ miss, Hassan Martin made one of two free throws with 9 seconds left to put the home team’s lead to four at 79-75. Jarreau hit another jumper with two seconds left to make it 79-77. Rhode Island tried to throw the inbound pass long. Donte Clark lunged and got his hand on it but couldn’t corral it. It bounced out of bounds with 0.3 seconds sealing the final result.

With Rashaan Holloway leading the way, UMass led by as many as 15 in the first half, when he single-handedly put the entire Rams frontcourt in foul trouble.

The Minutemen led 38-27 1:31 before intermission before the Rams mounted their own half-ending run. They scored the last 7 points to go into the break down 38-34.

“We have to learn when we’re up to control the game,” said Clark, who finished with 12 points.

The teams played close throughout most of the second half until E.C. Matthews put the Rams (11-6, 3-2 Atlantic 10) on his back late. The redshirt-junior guard has been inconsistent all year after missing 2015-16 with an ACL tear. But he looked like the first-team all-conference player he was projected to be down the stretch.

During a 12-3 run that swelled the Rams lead from 1 point to 7, at 75-68 with 1:38 left, Matthews scored 9 points and assisted on Kuran Iverson’s 3-pointer that put UMass in the hole that was too deep to emerge from.

“They made a few more plays than we did down the stretch on a couple of really tough shots that E.C. made that gave them separation,” Kellogg said. “They were tough shots. He made some fade-aways that were older-veteran plays.”

He finished with a game high 22 points for the Rams, while Hassan Martin, who was questionable to even play Sunday morning, had 17 points and blocked 6 shots.

Holloway led UMass with 20 points, 7 rebounds and 2 blocked shots before fouling out. Pipkins added 10.

URI didn’t shoot free throws well, making 21 of 38, but the Rams made more than UMass (13-for-18) attempted and their ability to get to the line helped decide the game.

The Minutemen (11-7, 1-4 A-10) will host Saint Joseph’s Wednesday at 7 p.m. They’ll host Rhode Island in the rematch on Feb. 7.

“That was a typical Rhode Island-UMass game that was hard fought and came down to the wire,” Kellogg said. “Both teams competed at a high level and they made some really big plays in that stretch.”