Stanford's comeback victory that stunned Oregon was enough of a roller-coaster that coach David Shaw felt the need to apologize to his parents and any other fans older than 70 for the emotional toll.

The Cardinal overcame a blown lead and had their banged-up quarterback stage an improbable rally before finally prevailing over the third-ranked Ducks.

Tanner McKee threw a TD pass on an untimed down at the end of regulation to tie the game and another on the opening possession of overtime to lead Stanford to a 31-24 victory Saturday.

"The key word is resilience," Shaw said. "It's the mark of a successful team, it's the mark of a successful person. How can you withstand the storms that life gives you? ... Our guys took it on the chin quite a bit but we fought back and made some big plays."

CLICK HERE FOR MORE SPORTS COVERAGE ON FOXNEWS.COM

McKee came back after leaving for a play on the final drive of regulation with injured ribs to tie it on a 2-yard pass to Elijah Higgins after a holding penalty by Oregon (4-1, 1-1 Pac-12) in the end zone extended the game one play.

McKee then gave the Cardinal (3-2, 2-1) the lead with a 14-yarder to John Humphreys in overtime. Stanford then forced Anthony Brown to throw an incomplete pass on fourth-and-8 to seal its fourth win against an Oregon team ranked in the top 10 since 2009 and set off a wild on-field celebration with the students and players.

"We were all on cloud nine. Just pure joy," linebacker Gabe Reid said. "There were a lot of ups and downs. We tried to say consistent with our energy and our passion. We like to think we deal with adversity well."

The Ducks appeared poised for their first 5-0 start in eight years when they rallied from 10 points down at halftime to take a 24-17 lead early in the fourth quarter on Brown's second TD run of the game.

But then McKee delivered the big plays late and the Cardinal capitalized on three Oregon penalties on the game-tying 87-yard drive in the final 1:59 of regulation.

"We had some bright moments, but certainly not enough to overcome some of our own mistakes," coach Mario Cristobal said. "We didn’t play with enough discipline today and we didn’t coach with enough discipline today. It ends up costing us the game."

McKee left the game for one play on the drive after being hit in the ribs by Kayvon Thibodeaux on a play ruled targeting. Oregon was then called for another roughing the passer penalty and the holding penalty in the end zone on what appeared to be the final play.

The Cardinal got the untimed down and McKee delivered with the pass to Higgins. Shaw opted for the extra point and the game went to OT.

"He’s a gritty dude," Higgins said about McKee. "That's what we expect out of him and he expects out of himself."

THE TAKEAWAY

Oregon: The Ducks played without offensive coordinator Joe Moorhead, who was being evaluated for a non-COVID-related illness. Oregon struggled to move the ball early with only one first down on the opening three drives and one score in the first half. Brown threw the first INT of the season for the Ducks on the second drive before getting going a bit in the second half.

"It’s not good enough," Brown said. "A team as good as ours can’t make mistakes like this. Can’t shoot ourselves in the foot. We did it a lot. It’s going to sting. It’s going to sting bad."

Stanford: The Cardinal had a strong first half and led 17-7 thanks to an 18-yard TD pass from McKee to Brycen Tremayne and a 2-yard run by Isaiah Sanders. They went three-and-out on three of the first four drives in the second half before the game-tying drive.

FOURTH-DOWN CALLS

Both teams were stopped on fourth down in the first half. Stanford went for it on fourth-and-1 just across midfield late in the first quarter but McKee was stopped for no gain on a sneak.

The Ducks took advantage of the short field and drove for a TD to cut the deficit to 10-7.

Then late in the half, Oregon went for it on fourth down from the 1 but Brown was hit for a 1-yard loss.

INJURED

Tremayne had to be taken off the field on a cart after an apparent leg injury in the first half. Before leaving the field, all his teammates came out to wish him well.

Oregon running back CJ Verdel then was taken to the locker room on a cart after getting injured in the third quarter. Verdell ran for 63 yards and a TD.

UP NEXT

Oregon: Hosts California on Oct. 15.

Stanford: At Arizona State on Friday night.