PASADENA — There were some who said UCLA had a puncher’s chance Saturday against seventh-ranked Stanford. The Bruins proved they did, until the Pac-12s biggest heavyweight decided to deliver the knockout punch.

Trailing from nearly start-to-finish, the Cardinal scored 13 points in the game’s final 24 seconds to escape with a thrilling 22-13 victory over UCLA in a Pac-12 game front of 70,833 fans at the Rose Bowl.

The victory – its seventh in a row and ninth straight against the Bruins – improved Stanford’s record to 3-0, 2-0 Pac-12, and kept its playoff hopes alive.

“We took some body blows, but we persevered,” said Stanford coach David Shaw. “(UCLA) Coach (Jim) Mora and his staff did a great job. They kicked our backsides pretty well, and often, on both sides of the ball tonight.”

That is until the final 2:05 of the game.

Following a 37-yard field goal by UCLA’s JJ. Molson that gave the Bruins a 13-9 lead, Stanford took over on its own 30 and produced its best drive of the game.

Cardinal quarterback Ryan Burns – who struggled throughout the game, completing just 13 of 25 passes for 137 yards – three huge times to Trenton Irwin of 23, 14 and 7 yards, and another of 13 yards to JJ Arcega-Whiteside. Irwin led all receivers with seven catches for 81 yards.

Faced with a second-and-goal at the Bruins’ 7, Burns hit Arcega-Whiteside once more, this time on a 7-yard touchdown pass that needed every bit of Arcega-Whiteside’s 31 1/2-inch vertical on a fade pattern near the back of the end zone to give Stanford its first lead since the opening drive of the game.

“That was surreal,” said Arcega-Whiteside. “We practice that after every practice, but to do it in a game…it just feels great to help the team win.”

Stanford placed the final touches on the victory moments later when Cardinal defensive end Solomon Thomas ran back a fumble 42 yards for a touchdown following a blindside sack of UCLA quarterback Josh Rosen by Joey Alfiieri on the final play of the game.

“Our defense stepped up,” said Heisman Trophy hopeful Christian McCaffrey.

McCaffrey was held in check for most of the game but still managed 138 yards rushing on 26carries.

“Ryan struggled, but in the end he was cool; he was clam and executed,” said Shaw.

Before the two, fourth-quarter scores, Stanford managed just three field goals by Conrad Ukropina of 37, 37 and 44 yards.

“I don’t have enough time to explain why our offense struggled,” said Shaw. “All I know is that we have to do a better job or we will lose Friday night against Washington.”

The first quarter witnessed an appearance by junior quarterback Keller Chryst, who came in after Burns was intercepted by UCLA linebacker Kenny Young in the first quarter. Six plays later, Bruins quarterback Josh Rosen hit tight end Nate Iesse for a 10-yard touchdown to give UCLA a 7-3 lead.

Burns re-entered the lineup after sitting out one series.

“Burns was not pulled,” said Shaw. “Keller was slated to play the third series of the game.”

Stanford committed its second miscue of the first half when Bruins defensive back Adarius Pickett recovered a fumble in the second quarter after teammate Tahaan Goodman jarred the ball loose from Cardinal wide receiver Francis Owusu following a 17-yard reception at the Bruins 20.

Owusu was shaken up on the play and did not play the rest of the game.

UCLA again took advantage of the Cardinal turnover, scoring on a 27-yard field goal by Molson with 2:01 left in the half following a 70-yard, 13-play drive.

Stanford marched 50 yards on 10 plays on its first drive of the game, before settling for a 37-yard field goal by Conrad Ukropina.

Stanford’s second possession of the second half began promisingly following runs of nine and 5 yards by McCaffrey, and a 30-yard run on a reverse by Bryce Love. But the drive stalled just inside the Bruins 20, leading to a 37-yard field goal by Ukropina.

Stanford’s next drive was much of the same. Runs of 8, 6 and 9 by McCaffrey led to a 44-yard field goal by Ukropina.

UCLA responded on its ensuing drive. Rosen hit Iese for receptions of 20 and 11 yards, and coupled with tough inside runs, marched inside Stanford’s 20 before Molson booted a 35-yard field goal with 6:32 left in the game.

Rosen finished 18 of 25 for 248 yards.

Stanford has not lost since falling to Oregon 38-36 on Nov. 14, 2015.