BERKELEY, Calif. -- It took a little bit of luck and a pair of big free throws from Dorian Pickens in the final seconds to keep Stanford from getting swept by California this season.
More critically, the Cardinal kept their hopes alive for a first-round bye in the Pac-12 tournament, a break that would be huge for coach Jerod Haase's team.
Daejon Davis scored 22 points before fouling out, Pickens made two free throws with 8.7 seconds remaining and Stanford overcame an erratic second half to beat California 77-73 on Sunday.
"We let the last one (against Cal) slide at home and our whole focus was making sure we finished and we don't look back," Davis said. "We just want to finish every game as strong as we can."
The Cardinal (14-13, 8-6 Pac-12) led by eight late in the second half before California rallied to make it 67-all following Don Coleman's free throw with 4:31 left.
Stanford scored the next five points but Davis fouled out with 2:11 remaining. With its assist leader on the bench, the Cardinal struggled against Cal's pressure defense and managed only five points after Davis fouled out.
It was just enough for Stanford to avoid a season sweep and earn its first win at Haas Pavilion since Jan. 14, 2015.
That left the Cardinal tied with Washington in the Pac-12 at 8-6, a half-game behind fourth-place Utah. The top four teams receive a first-round bye in the conference tournament.
"The ending wasn't how we wanted but overall I felt we played a much cleaner game," Haase said. "Our competitive spirit was there."
Davis, the Cardinal's quick freshman who shot 7 of 10 from the field, added five assists and seven rebounds. Pickens scored 17 points and Reid Travis added 13 points and 10 rebounds for Stanford.
The second matchup between the Bay Area rivals this season in many ways mirrored the first one in December when Stanford seemed in control early but blew a 17-point lead in the second half and lost to California in the Pac-12 opener.
This time the Cardinal hung on despite their problems against the Golden Bears pressing defense. Stanford committed 16 turnovers that led to 21 points for California, a large chunk of that coming after halftime.
"We were making a lot of passes backwards," Davis said. "At halftime and even in the last media timeout we just told our guys to not be passive and try to look up the floor more and get it to the outlet."
"For 40 minutes I felt like we gave everything that we had so I'm happy," Bears coach Wyking Jones said. "It was good to see that and feel that in the building."
Davis had two assists and made an eight-foot floater on Stanford's first three possessions before going to the bench with his second foul less than four minutes into the game. He returned 3 1/2 minutes later when Cal was in the midst of a 12-3 run.
The Bears went on another run and led 36-32 before Davis hit a 3-pointer and made a pair of free throws to put the Cardinal in front at halftime.
Stanford made seven consecutive free throws midway through the second half and led 63-55 before Cal made its push.
Stanford: The Cardinal shot 50 percent in the first half and controlled the boards but were sloppy taking care of the ball and committed 10 turnovers before the break. .
California: The Bears missed eight of their first nine, and finished 3 of 18 (16.7 percent), from 3-point range.
Primarily a man defense team most of the year, Stanford switched to a zone early in the second half that gave Cal some trouble. "They really packed it in so they pretty much dared us to shoot the ball," Jones said. "We have to do a better job of getting in the lane and looking for guys."
Stanford: Hosts Washington on Thursday.
California: Hosts Washington State on Thursday.
Ex-Baylor star Austin scores 14 in debut at TBT
Isaiah Austin made his American professional debut, scoring 14 points in Friday's opener of The Basketball Tournament.
TBT 2019 schedule, tip times, TV info, expert picks
The $2 million TBT begins on Friday. Here's info on how to watch and who our experts are picking to win The Basketball Tournament.
Auburn expects notice of allegations in hoops
Auburn expects to receive a notice of allegations from the NCAA over Chuck Person's role with the program.