DeAndre Daniels had 15 points for UConn (9-1), which was 6 of 10 from behind the arc in the first half and 0 for 12 in the second.
Randle's jump shot with 3 1/2 minutes left gave the Cardinal a 52-49 lead. The Huskies pulled within a point when Daniels tipped in a missed 3-point attempt by Niels Giffey.
But Shabazz Napier missed three shots in the final 40 seconds with a chance to put the Huskies ahead. He gave up an opportunity on UConn's final possession, passing the ball to Omar Calhoun, whose 3-pointer from the right wing bounced off the rim.
"I felt like Omar was the most open guy at the time," Napier said. "I felt like it was going to go in, and I bet he did too."
Napier, who finished with 12 points and eight assists, missed two 3-pointers on a key possession with the Huskies trailing 52-51. Stanford got the ball back with 28 seconds left after a scrum underneath the basket.
Napier fouled Huestis on the inbounds play and he hit one of two free throws.
Napier, who beat Florida with a jumper at the buzzer earlier this month, missed another shot with 8 seconds left, forcing UConn to foul again.
He got the ball back on a rebound after Huestis missed another free throw. He dribbled down the court, but instead of trying a contested shot, he passed to Calhoun.
UConn led by 10 points at halftime and pushed the lead to 43-30, before consecutive 3-pointers by Anthony Brown and Randle. That started a 14-0 run by the Cardinal, who used a stifling zone defense to hold the Huskies without a field goal for more than 6 minutes. The Huskies were just 5 of 31 from the field in the second half.
"It was just a matter of us being aggressive on the defensive end," Randle said. "Just being active, getting our hands moving, getting our feet moving and getting our feet moving and just hustling."