Behind an unrivaled resilience on both sides of the ball, the Trojans embodied the “one team, one heartbeat” message that interim head coach Ed Orgeron had been preaching to them all week leading up to Saturday’s showdown with the No. 4-ranked Stanford Cardinal.

Making his mark · USC interim head coach Ed Orgeron celebrates during the Trojans’ dramatic 20-17 victory over Stanford. The win was the program’s first time beating the Cardinal since the 2008 season. – William Ehart | Daily Trojan

And on one kick, with the game hanging in the balance tied at 17-17, USC junior kicker Andre Heidari, who had struggled all season and nearly lost his starting job weeks ago, was able to lift the Trojans (8-3, 5-2 Pac-12) to an upset victory over the Cardinal (8-2, 6-2). One final stop by the USC defense sealed the 20-17 victory in front of a sold-out crowd at the Los Angeles Memorial Coliseum.

Heidari’s 47-yard field goal with just 19 seconds remaining was the deciding factor that allowed the Trojans to shock a Stanford team that was coming off of an upset of their own when they defeated then-No. 3 Oregon 26-20 just over a week ago.

Though he has had his struggles this season and nearly lost his starting job, Heidari was able to deliver in the game’s most pivotal moment.

“I did what I needed to do,” Heidari said. “I’m glad my team put me into the position and that my teammates believed in me.”

It was apparent throughout the game that the College GameDay hype that began very early Saturday morning at McCarthy Quad transitioned to the Coliseum. The Trojans fed off of that energy, defeating Stanford for the first time since 2008.

Once the clock ran out, thousands of fans poured onto the field to celebrate USC’s first victory over a ranked team since 2011 and congratulate a team that has been playing inspired football since Orgeron took over for former head coach Lane Kiffin.

“This was a win for the entire Trojan Family,” Orgeron said. “I’m happy for the fans, it’s been a long time coming.”

The Trojans are 5-1 with Orgeron at the helm, spurring even more conversation that the former defensive line coach could be named USC’s permanent head coach once the season ends.

“Obviously there’s going to be some decisions made here after we play UCLA,” Orgeron said. “That [decision] is out of my hands.”

With all the excitement over his team’s marquee victory, Orgeron had plenty of things to focus on other than his job status come season’s end. The man who has been involved with the USC football program for more than a decade was elated for his players and assistant coaches to come away with such a big win.

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

On a night when former USC quarterback and Heisman Trophy-winner Matt Leinart led the team out of the tunnel, redshirt sophomore quarterback Cody Kessler looked sharp against a tough Stanford defense. He threw for 288 yards and one touchdown while completing 25 of his 37 passes.

In the first half, only two of Kessler’s pass attempts were incomplete.

The most crucial play of the night came on a fourth-down conversion with just over one minute left in the game. Kessler found junior wide receiver Marqise Lee on fourth and two for a 13-yard gain that extended the Trojans’ eventual game-winning drive. Lee proceeded to hobble off the field following the play, due to what he thought was a bone bruise.

“I knew I was taking a chance,” Orgeron said of the decision to leave his offense on the field on fourth down. “But I looked inside their eyes, and as a coach, I wanted to give the guys a chance to win the game. I had no hesitation at all to go for it.”

Lee, who claimed he felt 100 percent earlier in the week, finished the night with six catches for 83 yards.

“I knew he was in pain, but I had trust in him that he was going to be open, and I just threw the ball and he was there to make the play,” Kessler said.

When the offense began to struggle in the second half, it was the Trojans’ stalwart defense that made the big plays USC needed in order to stay in the game.

After Kessler fumbled deep in USC territory, the defense kept the Cardinal out of the end zone and forced a field goal attempt. The kick was blocked by redshirt freshman offensive tackle Chad Wheeler to keep the game tied at 17-17.

In the fourth quarter, Stanford had the ball at the USC 10-yard line when redshirt junior safety Dion Bailey intercepted Cardinal quarterback Kevin Hogan’s pass and returned it to the USC 34-yard line, sending the Coliseum crowd into a frenzy.

“It was one of the most electrifying atmospheres I have played in in my four years here,” Bailey said. “This was a great win for the university.”

With only three minutes remaining to play, the defense again rose to the occasion when freshman safety Su’a Cravens intercepted a deflected pass from Hogan that set up the USC offense for a drive that ultimately won the game.

Stanford’s 17-point offensive output was the fewest points scored for the Cardinal this season.

“An outstanding job by [defensive coordinator] Clancy Pendergast, [defensive line coach] Pete Jenkins and all of our linebackers for hanging in there toe-to-toe with the Stanford offensive line,” Orgeron said.

The USC running game, which had been so successful in recent weeks, was held in check by the vaunted Stanford defense, gaining just 23 yards on 27 attempts. Redshirt sophomore running back Javorius ‘Buck’ Allen scored a one-yard rushing touchdown late in the first quarter to give USC a 14-7 lead.

Stanford’s running game, however, was relentless and paced its offense, as the Cardinal rushed for 210 yards on 35 carries behind their stout offensive line. Cardinal running back Tyler Gaffney had 24 carries for 158 yards and two touchdowns.

Gaffney scored on a 35-yard run in the first quarter to answer Kessler’s one-yard touchdown pass to redshirt sophomore fullback Soma Vainuku on the Trojans’ first drive of the game.

USC’s win was its first home victory against Stanford in its last three meetings. In 2011, Stanford outlasted USC in a classic triple-overtime loss against then-Cardinal quarterback Andrew Luck.

The Trojans not only derailed Stanford’s national title aspirations by pulling off the upset, but also kept their own Pac-12 championship and Rose Bowl hopes alive. With two games remaining, USC would win the Pac-12 South by winning its final two games and having Arizona State lose its final two games.

For the time being, though, Orgeron and the rest of the team are not concerned with their place in the standings. Coming off of the biggest win for the program in nearly two years, the team plans on simply enjoying the moment.

“To see [the players] smiling and happy with winning, that’s all we want as a staff,” Orgeron said. “Besides going to the big bowl games and beating UCLA, this is probably the best.”