Andre Heidari had been waiting for the moment his whole career.
USC's junior kicker nearly lost his job a few weeks ago and was struggling going into Saturday night's game against fifth-ranked Stanford.
Still, he remained confident.
"You want to prove that you can make a game-winning field goal when it's on the line," he said this week. "That's what I play for."
Heidari got his chance late in the game and he came through with a 47-yard field goal with 19 seconds to play, giving USC a 20-17 upset victory before a delirious sellout crowd at the Coliseum.
Fans stormed the field after a victory that improved USC's record to 8-3 overall and 5-2 in the Pac-12 Conference. It also extended the Trojans' winning streak to four games and improved interim Coach Ed Orgeron's record to 5-1 since taking over for the fired Lane Kiffin.
USC ended its four-game losing streak against Stanford with its first victory over the Cardinal at the Coliseum since 2005.
Stanford fell to 8-2 and 6-2 in the Pac-12.
Freshman safety Su'a Cravens set up the game-winning field goal by intercepting a tipped pass with just over three minutes remaining.
Orgeron, who had elected to punt on a fourth and one two series earlier, this time opted to go for it on fourth and two at the Stanford 48 with 1:23 remaining.
"I looked into these guys' eyes and knew they wanted to go for it and win the game," Orgeron said.
Quarterback Cody Kessler completed a nine-yard pass to receiver Marqise Lee for the first down and Kessler completed another pass to Nelson Agholor that moved the ball to the 21.
After losing ground on three plays, on came Heidari.
The Bakersfield product had kicked 50- and 22-yard field goals two years ago in the Trojans' 56-48 triple-overtime loss to the Cardinal at the Coliseum.
But last week, he missed a field-goal attempt and an extra-point against California. Last month, he missed two field-goal tries in a 14-10 loss at Notre Dame. And he missed an extra-point try Saturday after USC's first touchdown.
But none of that mattered when his kick with 19 seconds left split the uprights at the peristyle end of the stadium.
Heidari, who also kicked a 23-yard field goal in the second quarter, sprinted joyously down the field as teammates chased him to the opposite end zone.
"It's a dream for me," he said. "A dream come true."
The kick itself, Heidari said, was "a regular kick. It's the same kick every time. Three steps back, two steps over, line it up, hit a target pretty much. I did what I needed to do. I'm just thankful for my team that it put me in that position."
USC had extra reason to celebrate. In 2010, it lost to Stanford on a last-second field goal at Stanford Stadium. In 2011, Stanford clinched its triple-overtime victory on the final play when USC tailback Curtis McNeal fumbled into the end zone.
"Happy for the fans," Orgeron said. "It's been a long time coming."
Kessler completed 25 of 37 passes for 288 yards, including a touchdown to fullback Soma Vainuku.
Tailback Javorius Allen ran for a touchdown. Receiver Nelson Agholor had eight catches for 104 yards.
Safety Dion Bailey also intercepted a pass for a Trojans defense that withstood the Cardinal's powerful running game.
"They have a good team and they got healthy at the wrong time for us," said Stanford Coach David Shaw.
Linebacker Anthony Sarao led USC with 12 tackles and linebacker Hayes Pullard had 11. USC's special teams also came up big when lineman Chad Wheeler blocked a field-goal attempt in the third quarter.
Wheeler, the starting left tackle on offense, also helped keep Kessler mostly out of harm's way, though he was sacked and fumbled in the third quarter.
USC had taken a 17-10 halftime lead on Vainuku's short touchdown reception, Allen's short touchdown run and Heidari's first field goal.
But USC's momentum dissipated as it stalled on its first third-quarter series, opening the door for Stanford, which then seemed to revert to the form of its Nov. 7 win over Oregon.
Starting at its eight yard-line, Stanford marched methodically downfield, until running back Tyler Gaffney tied the score with an 18-yard touchdown run. Gaffney had 158 yards in 24 carries.
USC gave the Cardinal another chance when Trent Murphy sacked Kessler, forcing a fumble that linebacker Shane Skov recovered.
The Trojans averted potential disaster when Wheeler blocked a field-goal attempt. Then, early in the fourth quarter, Bailey's interception of a Kevin Hogan pass on third and goal at the USC 10 denied the Cardinal again.
Bailey said Stanford had run the same play earlier in the game and he "made a mental note." This time the Cardinal ran the play to the opposite side, but Bailey said he still recognized it.
"I knew [it] was coming again. I turned around and the ball was coming," he said.
From there the teams exchanged punts, until Cravens' interception and Orgeron's fourth-down gamble paved the way for Heidari.
"We came over to the sideline and . . . Coach O looked at us and no one really said anything," Kessler said of the moments before the fourth-down play. "He looked at us in the eyes and [offensive coordinator Clay] Helton looked at him and said, 'We can do this' and Coach O said, 'I know we can.'
"Coach Helton called a great play. Marqise was hurting but he said, 'I got one more in me.'"
Said Orgeron: "I felt that that was the time to do it. . . . If we wouldn't have made it, [Stanford] could have gone down there and kicked a field goal and won the game. I totally understood that."