LOS ANGELES -- Southern California's surge under interim coach Ed Orgeron has swallowed up No. 5 Stanford.
Andre Heidari kicked a 47-yard field goal with 19 seconds to play, and USC's stalwart defense repeatedly came up big in a 20-17 upset of the Cardinal on Saturday night.
Cody Kessler passed for 288 yards as the revitalized Trojans (8-3, 5-2 Pac-12) earned their fifth win in six games under the irrepressible Orgeron, who replaced the fired Lane Kiffin in late September.
"In our tight-knit family, there was a belief that we were going to find a way to win the game," Orgeron said. "I'm proud of our young men. This is something that they've wanted for a long time now."
USC's remarkable defensive performance included two fourth-quarter interceptions and a season-low 17 points from the powerful Cardinal (8-2, 6-2), who followed up last week's win over Oregon by getting knocked out of the national title chase and maybe the Rose Bowl race as well.
Heidari nearly lost his job twice this season, and he missed an extra point in the first quarter. But the junior coolly nailed the tiebreaking field goal - and then got an unsportsmanlike conduct penalty for running the length of the field to celebrate it.
After the inconsistent Heidari's field goal and Stanford's final play, thousands of USC fans stormed the Coliseum field, where Stanford had won in its last three trips, including a triple-overtime thriller two years ago.
Soma Vainuku caught an early TD pass and Javorius Allen rushed for a score for USC, which didn't score in the second half until Heidari's kick. Nelson Agholor had eight catches for 104 yards, while Marqise Lee had six catches for 83 yards - and both receivers made big plays on USC's final drive.
"I don't know if I pulled them together," Orgeron said. "I think they just came together. The leadership of this program is really coming to the forefront."
Tyler Gaffney rushed for 158 yards and two touchdowns for Stanford, which had won three straight while closing in on the chance to host the Pac-12 title game for the second straight year. Kevin Hogan went 14 of 25 for 127 yards, but the Cardinal couldn't regain the lead after trailing at half, despite repeatedly getting close.
After trailing 17-10 at halftime, Stanford calmly tied it with Gaffney's 18-yard TD run on the first drive of the third quarter. USC's offense struggled throughout the second half, but the Trojans' thin defense kept it close despite using just two substitutes for most of the night.
Dion Bailey intercepted Hogan's third-down pass at the USC 6 with about 10 1/2 minutes to play, killing what seemed certain to be Stanford's go-ahead drive. Su'a Cravens then intercepted a tipped pass at the USC 44 with 3 minutes to play, giving another chance to the Trojans' offense.
After Lee caught a 13-yard slant pass over midfield on fourth-and-2, the Trojans reached the Stanford 21 before two straight yardage-losing plays pushed them back to the 30 - and Heidari still nailed his kick.
USC hadn't beaten a ranked opponent since 2011, and the Trojans hadn't had much to celebrate during an up-and-down season that cost Kiffin his job. But USC has played with fire for Orgeron, the longtime defensive line coach whose raw enthusiasm has worn off on the program.
Orgeron wasn't thought to be a serious candidate for the Trojans' full-time job when he took over for Kiffin, but his players are pushing his name deeper into the discussion with each passing victory.
"Obviously there's going to be some decisions made here after we play UCLA (on Nov. 30)," Orgeron said. "That's out of my hands."
Under the lights at the sold-out Coliseum, Stanford betrayed a few nerves early. The Cardinal burned two timeouts and committed an illegal-snap penalty on the game's first drive, and Ty Montgomery dropped two passes in the opening minutes.
USC's opening drive was smooth, with Lee making a tiptoe sideline catch before Vainuku came out of the backfield for a play-action 1-yard TD catch just 6:13 in.
Gaffney scored on a 35-yard run moments later when he popped out the back of a scrimmage pile and sprinted past the slumbering USC defense, but the Trojans answered with another long drive capped by Allen's 1-yard TD run and a 2-point conversion catch by Lee.
Kessler was outstanding in the pocket and on the run, completing 10 straight early passes before Heidari's field goal put the Trojans up by 10 points early in the second quarter. Stanford added a field goal with 17 seconds left the first half.
After Gaffney capped a 92-yard drive with his TD run up the middle, Stanford forced a fumble by Kessler at the USC 19, but the Cardinal's field goal attempt was blocked.
Stanford is USC's oldest rival in a series dating back to 1905. The Cardinal had never won four straight in the series before the last four meetings.
Former Stanford lineman Jonathan Martin watched the game from the sideline in a backward Cardinal cap.