Matt Scott had three touchdowns through the air and one on the ground as Arizona took down No. 10 Southern California, 39-36, in Pac-12 action.
Scott went 27-for-50 with 369 yards and an interception and added 15 runs for 100 yards for the Wildcats (5-3, 2-3), who have won two straight after dropping their first three conference games.
Ka'Deem Carey had 28 carries for 119 yards and a touchdown while Austin Hill posted 10 catches for 259 yards in the win.
"I'm really proud of our guys. They hung in there," Arizona coach Rich Rodriguez said. "It feels good to win a close one."
Matt Barkley threw for 493 yards and three touchdowns on 31-of-49 attempts, but did get picked off twice for the Trojans (6-2, 4-2), who had a three-game winning streak snapped.
Marqise Lee had a monstrous game for USC as he broke the Pac-12 record with 345 receiving yards on 16 catches with two touchdowns in the loss.
Arizona trailed by two points going into the final frame, but took the lead on its first touch as a seven-play, 72-yard drive was capped on a 7-yard run into the end zone by Carey for a 32-28 lead with 10:46 to play. The big play of the drive was a 60-yard catch by Hill on a 3rd-and-22.
After a three-and-out from the Trojans, the Wildcats got the ball back just past midfield and added to their advantage on a 7-yard touchdown catch by David Richards for a 39-28 lead with 5:36 left.
Lee got the team into scoring position on the ensuing kickoff with a 72-yard return and that led to a 10-yard TD run from Silas Redd. Lee then caught the two-point conversion and it was a 39-36 game with 4:30 to play.
Arizona was unable to kill off the rest of the clock, but did get two first downs before handing the ball back to USC with 55 seconds left.
Starting at their own 13-yard line, the Trojans were able to get the ball close to midfield to set up a Hail Mary chance on the final play. Barkley heaved the ball down to the end zone, but it was batted away and Arizona took the upset win.
"It was a very discouraging loss today. It wasn't about effort. I thought our players had great effort. We made a lot of mistakes and weren't able to catch up," USC coach Lane Kiffin said.
USC got into the red zone on the opening possession of the game, but a personal foul call pushed the ball back and Barkley was later intercepted by Marquis Flowers.
The Wildcats had the ball at their own 40-yard line and a personal foul call on USC pushed the ball across midfield. A 30-yard catch from Hill gave the team a 1st-and-goal and two plays later, Scott hit Johnny Jackson in the end zone from eight yards out for a 7-0 lead with 7:20 left in the first.
The Trojans went for it on 4th-and-2 at the Arizona 15-yard line and Barkley's pass fell incomplete. On the first play, Scott and Hill got together on a 56- yard strike, leading to a 27-yard field goal from John Bonano for a 10-0 lead with 48 seconds to play in the first quarter.
After Arizona was unable to take advantage of a recovered fumble, USC got the ball back at its own 16-yard line and put together a drive. A 50-yard catch from Lee got the ball into the red zone, and Xavier Grimble took it in with a 12-yard TD catch to make it a 10-7 game with 10:07 left in the first half.
Arizona had to punt on its next touch and a 15-yard interference call to the team on the punt saw USC start just pass midfield, but Barkley was picked off by Flowers for the second time.
The Wildcats failed on a 4th-and-15 at the USC 35-yard line and the Trojans needed just four plays to take the lead as Barkley and Lee got together on a 49-yard score and a 14-10 lead with 4:36 to play in the half.
Arizona answered with three points on a 44-yard field goal from Bonano with 2:38 to play, but USC came right back down the field and got into the end zone when D.J. Morgan punched it in from three yards out to give the team a 21-13 lead at the break.
The Wildcats lined up for a 27-yard field goal on the final play of the half and Bonano made it, but an offensive holding call pushed it back 10 yards and he missed his second attempt.
USC's first touch of the second half saw the team build on its lead as Barkley and Lee got together for a 44-yard score to cap a seven-play, 87-yard drive for a 28-13 advantage.
Arizona, though, chipped away at the deficit later in the third on a 10-yard run into the end zone by Scott and a fumble from USC was recovered by the Wildcats at the Trojans' 37-yard line and that led to a 9-yard scoring catch by Dan Buckner from Scott. The team went for two points and failed as it was a 28-26 game heading to the fourth.
There was a total of 1,206 yards of offense in the game, 618 from USC ... USC had won the previous two games against Arizona and still leads the series, 28-8 ... The teams combined for 27 penalties for 246 yards. Arizona was penalized 14 times for 129 yards ... Arizona plays at UCLA next Saturday ... USC returns home to face Oregon next week.