Mistakes and undisciplined play finally got the best of USC.

Arizona forced five turnovers by the Trojans and got 369 yards passing and 100 yards rushing from quarterback Matt Scott to upset 10th-ranked USC, 39-36, in a Pac-12 Conference game Saturday afternoon in Tucson, Ariz.

The loss dropped USC to 6-2 overall, 4-2 in Pac-12 play. Arizona improved to 5-3, 2-3.

USC lost despite a record day by receiver Marqise Lee, who had 469 all-purpose yards.

Lee caught 16 passes for a Trojans’ single-game record 345 yards and two touchdowns. He also ran one time for a yard and added 123 yards in three kickoff returns.

Quarterback Matt Barkley completed 31 of 49 passes for 493 yards and three touchdowns, but he had two passes intercepted. The Trojans also lost three fumbles and kept their worst-in-the-nation-for-penalties reputation intact as they were flagged 13 times for 117 yards.

USC led 28-13 early in the third quarter after Barkley and Lee hooked up on a 44-yard touchdown pass, but Arizona roared back behind Scott and running back Ka’Deem Carey.

Scott completed 27 of 50 passes for three touchdowns with one interception. Carey rushed for 119 yards and a touchdown in 28 carries.

Arizona scored 26 unanswered points on a 10-yard run by Scott, a nine-yard pass from Scott to Dan Buckner, a seven-yard run by Carey and a seven-yard pass from Scott to David Richards. The Wildcats tacked on two point-after kicks after those four touchdowns, but failed on a pair of two-point conversion runs.

Arizona’s final touchdown march was fueled by a personal foul penalty on USC safety T.J. McDonald, who hit Scott in the head after he had slid to end a run.

However, that hit, the second personal foul penalty on USC for hitting Scott late -- linebacker Dion Bailey was penalized earlier -- eventually knocked the quarterback out of the game.

After his touchdown pass, Scott returned to the bench and vomited. He also exhibited other concussion symptoms.

Meantime, Lee was once again bringing USC back to life. He returned the ensuing kickoff 72 yards for the Arizona 27, then turned a short pass into a 17-yard gain that set up a 10-yard touchdown run by Silas Redd.

Barkley then connected with Lee again on a two-point conversion pass in the back of the end zone.

But Arizona, with backup quarterback B.J. Denker handing off to Carey, was able to grind out two first downs and take just enough time off the clock.

USC got the ball back with 55 seconds remaining on its own 13.

Barkley completed a pass to Redd for 13 yards, another to Lee for 15 yards, then went back to Redd for an 11-yard gain.

But another pass play for Lee took too long to develop down the left sideline and the Trojans were left 48 yards from the end zone with five seconds on the clock.

Barkley got off a Hail Mary pass to the end zone, but Lee, in a crowd of three Arizona defenders, couldn’t pull it in as the ball trickled off his fingertips.