USC (4-2, 3-1 Pac-12) left the Coliseum defeated and deflated a week ago after losing to Arizona State on a Hail Mary. The Trojans were headed toward another stinging loss after Jared Baker scored on a 1-yard with 1:07 left and Caleb Jones recovered the onside kick.
With the crowd roaring for another improbable victory, the Wildcats came up short when Casey Skowron missed his third field goal of the night, a 36-yarder that sailed wide right with 17 seconds left.
Arizona (5-1, 2-1) struggled with red-zone issues in the first half before mounting their comeback. Baker scored all three of his touchdowns in the second half, but was stuffed by USC's Leonard Williams on the 2-point try before the final flurry.
Arizona has had an emotional couple of weeks, rallying to beat California on a Hail Mary and knocking off then-No. 2 Oregon on the road last week.
The win over the Ducks vaulted the Wildcats from out of The Associated Press poll to No. 10 this week, the largest jump since the poll went to 25 teams in 1989.
Arizona's task was to avoid a letdown against the Trojans, who road into the desert with a different set of emotions after Arizona State's Hail Mary.
Oddsmakers predicated a Wildcats' hangover, installing them as 2½-point underdogs despite being undefeated and playing at home.
The Trojans played like favorites from the start, moving the ball successfully against an Arizona defense that contained the Ducks a week ago, particularly when they gave the ball to Allen.
The junior running back turned an inside handoff into a 34-yard touchdown run by bouncing it outside in the first quarter, then burst through a hole for a 48-yard score in the second.
Gaining yards was not a problem for Arizona.
Scoring touchdowns was.
The Wildcats crossed USC's 20 four times in the first half and came away with six points.
Skowron made two field goals, missed one and had another blocked. Arizona also lost a fumble late in the half, when Williams crushed Jones-Grisby at the 7-yard line to pop the ball loose.
USC led 14-6 at halftime in a game that was more defensive than anticipated.
Once the second half started, so did the offensive fireworks.
Kessler found Nelson Agholor on a 21-yard touchdown pass and Allen scored his third touchdown on a 1-yard run, putting the Trojans up 28-13.
Arizona finally the end zone in the third quarter, when Baker scored on a 6-yard run, four plays after the Wildcats recovered Justin Davis' fumble at USC's 22.
Baker scored again early in the fourth quarter, turning a fourth-and-3 into a 41-yard touchdown reception out of the backfield that cut USC's lead to 28-20.