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.”

Twitter: @latimesklein