STANFORD -- Maples Pavilion roared Wednesday night as Stanford had No. 1 Arizona on the brink of its first defeat.
But when Chasson Randle's 3-pointer bounced off the rim at the buzzer, the Cardinal had only a 60-57 loss to show for the gritty effort.
"I thought I got a good look at it," Randle said. "It was just one of those nights."
Stanford (13-7, 4-4 Pac-12) seized the lead in the final seconds of the first half and widened the advantage to seven while feeding off the energy of its first sold-out crowd of the season.
But Arizona tightened its defense, holding Stanford scoreless for nearly nine minutes, and got clutch plays from guard Nick Johnson down the stretch as it extended its program-record winning streak to 21 games.
Johnson's 3-pointer with 51 seconds left broke a 55-55 tie.
The Wildcats (21-0, 8-0) held on from there to give Aaron Gordon a win in his return to the Bay Area. The former Archbishop Mitty star did not have one of his best nights, finishing with five points on 2-of-10 shooting, but he was happy that his team survived.
"I'm not worried about self accolades or anything," Gordon said. "I just cared about the win, and that's what we got."
Bidding for its first win over a No. 1 team in nearly a decade, Stanford raced to an early lead and kept the score tight throughout. But just when it seemed as if it might give Johnny Dawkins the biggest win of his coaching career, the Cardinal could not score.
Josh Huestis' jumper gave Stanford a 53-49 lead with 10:03 left. The Cardinal did not score again until Dwight Powell's reverse layup with 1:21 to go tied the score 55-55.
"It's disappointing, especially the way we played," said Dawkins, who was proud of his team's effort. "But falling short means there are no moral victories. For us, we have to look at how we can get better. I think there is still a big upside to our team."
The Cardinal shot only 31 percent in the second half. Huestis and Powell led Stanford with 13 points apiece. Randle had 12 points on just 3-of-15 shooting.
"We're an outstanding defensive team," Arizona coach Sean Miller said. "It isn't as if we changed any scheme. We just buckled down and had a lot of players playing very hard, and our ability to hold them to what we did is a big reason we won. Our defense won the game tonight."
Stanford has not beaten a No. 1 team since December 2003, when it defeated Kansas 64-58 at the Wooden Classic in Anaheim. The Cardinal's last win over a No. 1 at home came 26 years ago, when it beat an Arizona team featuring Sean Elliott, Tom Tolbert and Steve Kerr 82-74.
Dawkins called the atmosphere Wednesday the best in his six seasons.
"The energy was fantastic," he said. "It was electric. For me it was so exciting to walk out there and see that type of support. Our guys definitely fed off of that."
But in the end, they fell short.
"Coming off any loss, it's tough to sleep at night," Huestis said. "But of course this is going to weigh heavily on guys' minds."
Follow Darren Sabedra on Twitter at twitter.com/DarrenSabedra.
Arizona State (16-5, 5-3 Pac-12) at Stanford (13-7, 4-4),
1 p.m. Pac-12 Networks
CAL: Bears rally to force overtime before losing 89-78 to Arizona State. PAGE 2
SANTA CLARA: Gonzaga wins 54-52 on 3-point shot with 1.9 seconds left. PAGE 2
ROUNDUP: San Jose State loses ninth straight, falling 70-46 to UNLV. PAGE 5