BERKELEY, Calif. – Mired in the middle of the Pac-12 race, the Arizona Wildcats rose up in the most unlikely of places Thursday.

The Wildcats handed first-place Cal its first home loss of the season, 78-74,  while winning their first game in six contests played this season decided by six points or less.

Kyle Fogg tied his season high with 23 points and made a key late block on Cal’s Allen Crabbe, while a subsequent block by Nick Johnson on Justin Cobbs preserved the win for Arizona.

The win moved Arizona to 15-8 overall and 6-4 in Pac-12 play. Cal, having lost its first home game of the season, dropped to 17-6 and 7-3.

Arizona led 75-72 entering the final minute but Jorge Gutierrez hit two free throws with 59 seconds left to cut it to one point.

After UA forward Jesse Perry scored inside to put the Wildcats ahead 77-74, Fogg blocked a three-pointer by Crabbe with 27 seconds to go. Josiah Turner then missed the front end of a one and one with 22 seconds left, giving Cal the ball.

But when the Bears’ Justin Cobbs drove inside, Nick Johnson blocked it and Perry recovered the ball with 11 seconds left.

Perry was fouled and hit one of two free throws to make it 78-74 but Cal failed to score on its final play.

Cobbs had tied the game at 72 with 3:40 left but Kyle Fogg made a three-pointer with 1:10 remaining to give the Wildcats a three-point lead entering the final minute.

The win did come with some bad news for the Wildcats: UA guard Jordin Mayes sat out the late second half with ice draped over his left foot. UA said it appeared to be a foot injury but the extent of it was not immediately clear. Mayes broke a foot last spring and had surgery on it in late June.

Cal went on a 9-0 run late in the game to cut the UA lead to two points late in the game, after the Wildcats took leads as big as 14 points earlier in the second half.

Solomon Hill sat out several minutes in the second half with four fouls but returned with 7:08 left when Cal began closing in.

Hill picked up his fourth foul with 14:45 to go and fouled out with 59 seconds left.

After digging themselves another early hole, Arizona went on a 30-8 run in the first half to take a 45-34 halftime lead.

Arizona forced eight Cal turnovers and kept the Bears without a three-pointer in three attempts from beyond the arc. Offensively, the Wildcats were led by Fogg, who had 13 points.

The Wildcats trailed by up to 13 points midway through the first back but used their defense to help trigger a comeback that put them ahead by five points with three minutes to go.

Forward Jesse Perry tied the game at 26 at the 4:44 mark and put the Wildcats ahead with a layup with 4:15 left. Fogg later hit a three-pointer to put UA up 31-28 and made a steal that led to a breakaway layup by Mayes that made it 33-28.

Arizona cut it to a basket, 24-22, with a furious run that included a jumper and three-pointer from Fogg, the latter after he was knocked hard by a defender, while Solomon Hill stole the ball and went in for a layup.

Earlier, Cal had gone up 18-9 with 11:18 left in the half and appeared to be in control. Two minutes earlier, UA coach Sean Miller called timeout with Cal leading 14-6 with 13:21 left in the first half.

At that point, the Wildcats were shooting 2 of 8 from the field and getting outrebounded 10-4.

Arizona was wearing its red road uniforms for the second time this season. The Wildcats lost to Gonzaga 71-60 on Dec. 17 in the only other game they have worn red this season.