Three undefeated teams remain in college basketball. Arizona is still one of them.

Barely.

The Wildcats can thank its sensation in sneakers, Nick Johnson, who hit a key 3-pointer with 51 seconds left and got a crucial rebound on Stanford's next possession.

In a season of near misses on Arizona's magic ride to 21 consecutive wins, Johnson has been Arizona's genie, and he was again in lifting the Wildcats to a huge 60-57 win on the road.

It was Johnson's 3 that gave Arizona the lead and the cushion it needed. It came after a Kaleb Tarczewski rebound that coach Sean Miller called "huge."

"That (rebound) was the biggest play of the game," Miller said on his postgame radio show. "Nick's shot would not have happened if he didn't get the rebound."

Of course, not all was perfect. Even if top-ranked Arizona (21-0, 8-0 Pac-12) remains undefeated along with Syracuse and Wichita State.

For the first time this season, Arizona was outrebounded, 38-36. Stanford was able to keep the pace to a slower-than-usual one for the Wildcats. Arizona shot 36 percent from the floor and 62 percent from the free throw line.

"Stanford did a real good job of keeping us off the offensive glass," Miller said. "I give Stanford a lot of credit. I don't know if our guys were not going like we normally do. I just thought that they did a good job. I think we can do better."

Johnson had 16 points to lead Arizona. He added five rebounds and four assists. Teammate T.J. McConnell had 11 points, eight rebounds and four assists.

All wasn't perfect for Johnson, though, as he missed a free throw with 33 seconds left to give Stanford a shot at a tie. He then came back with 5.8 seconds left and hit two free throws for the game's final points.

When Chasson Randle raced down and attempted a 3-pointer and missed, it was over. Stanford's bid to beat Arizona for the third time as the top-ranked team was gone.

What else but a down-to-the-wire game? It usually happens at Maples Pavilion, where Arizona need a miracle or two to pull off past victories.

Khalid Reeves raced the length of the court in the early 1990s to give Arizona a last-second win; Michael Wright hit a last-second basket in the early 2000s; and Damon Stoudamire, now an assistant coach, had to score 45 points in an overtime win.

Stanford has always been tough for Arizona. Wednesday night was no different.

"I credit Stanford because I thought they had a good game plan," Miller said. "They've got great experience and size on the court. The way they decided to play us, we needed to make a few more perimeter shots.

"When we got to the foul line, we needed to convert."

Arizona hit 18 of 29 free throw, or just enough to get by. It's been Arizona's most noticeable problem so far this year; the Wildcats went into the game hitting just 64 percent from the line.

"If we would have converted more from the foul line, the game would have felt differently from start to finish," Miller said. "Our guys have a lot of resiliency. Nick Johnson's plays at the end were as big as you come up with, especially in conference play."

Arizona's offense was out of sync early. The Wildcats missed seven of their first eight shots and was down again to begin the game.

"There were times, although I'd like to give Stanford all the credit defensively, we didn't just struggle because we didn't hit open shots or free throws, but we didn't execute at times as well as we could have all season long," Miller said.