Trailing at home, 46-45, against Arizona State with 2:35 left in the game, Cal football needed just one more scoring drive to put the game away. On a night when Jared Goff threw for a career-high 542 yards and five touchdowns, the junior quarterback came through.

No matter what the Sun Devils tried to throw at Goff, nothing worked. Prepared for any sort of defensive scheme ASU tried, Goff led his team down the field to set up kicker Matt Anderson for the 26-yard field goal. With just four seconds left, Anderson hit the game winner to give Cal the 48-46 win at Memorial Stadium.

“I didn’t even really see the kick go through,” Anderson said. “I just got swarmed.”

With Cal losing by 24-3 at one point, the fireworks to end the game seemed unlikely, considering the lackluster play from both its offense and defense. In the first half, the Bears looked tired and underperformed. But after halftime, Cal pieced together its best 30 minutes of the year to climb back into the game and finish the season in historic fashion.

“Coach (Sonny) Dykes said to us at halftime, ‘They’re not really stopping us — we’re just killing ourselves,’ ” Goff said. “But we knew that if we did what we were supposed to do, they wouldn’t be able to stop us.”

Similarly to last week’s game against Stanford, sloppiness and unforced errors hurt Cal in the beginning.

On the Bears’ opening drive, Goff drove down the field with little pressure from the defense. But when the Bears were knocking at the door on Arizona State’s 21-yard line, a 15-yard offensive-pass-interference penalty committed by senior receiver Maurice Harris forced a first and 25, which eventually resulted in the Bears settling for a field goal.

Then, at the 2:29 mark in the first quarter, Cal freshman receiver Kanawai Noa muffed a punt that the Sun Devils recovered on the Bears’ 10-yard line. Three plays later, redshirt senior quarterback Mike Bercovici connected with redshirt senior Devin Lucien for the 9-yard touchdown catch to give ASU the 10-3 lead.

The rest of the half would be a nightmare for the Bears. With the offense struggling to move the ball and Lucien abusing its secondary, Cal fell behind quickly and watched as ASU extended the lead. At one point, the Sun Devils led, 24-3, and by the end of the half, their lead was 27-10. The defense had no answer for Lucien, who finished the first half with 107 yards and three touchdowns.

Like in many games this season, the Bears found themselves trailing by multiple scores early on. And as a team that relies heavily on the pass, Cal was forced to rely on Goff’s arm to bring the team back and gave its running backs limited opportunities to carry the ball. At halftime, the Bears had run the ball just six times for a total of 20 yards, while Goff had thrown the ball 25 times.

The second half was a different story, as both Cal’s offense and defense woke up.

Fueled by big downfield throws from Goff and a use of the running game, the Bears’ offense put together two quick touchdown scoring drives in the third quarter — one that ended with a Tre Watson run, and the other, a Chad Hansen catch. On those two drives, the Bears racked up a combined 169 yards in just 2:27. Cal would have one more touchdown drive later in the quarter off a red zone connection from Goff and Harris.

“Once we got a touchdown in the third, I feel like everyone believed, ‘Aye, we’re coming back, and we’re going to win this game,’ ” said senior safety Stefan McClure.

While Cal was scoring touchdowns, ASU was kicking field goals. The defense also adjusted and found ways to quiet the Sun Devils. By improving on pass coverage to prevent the deep throws and making the tackles they were missing in the first half, the Bears made moving the chains exceptionally harder for ASU. Most importantly, the defense made plays when the Sun Devils were threatening to score in the end zone, forcing ASU to kick field goals while deep in Cal territory twice.

“We knew if they kept (forcing field goals), we were going to win the game,” Goff said.

Led by Goff’s 188 passing yards for two touchdowns on 10-18 in the quarter alone, the Bears dominated the third, 21-6, and erased a once three-possession deficit to just 31-33 entering the fourth.

And Cal wouldn’t slow down in the final quarter. After forcing ASU to settle for another field goal, the Bears immediately continued their offensive surge. Goff, back on the field, threw his fourth touchdown to sophomore running back Khalfani Muhammad, who was wide open on a wheel route. With just one defensive back to beat, the speedy Muhammad juked his way for the 58-yard score to give Cal its first lead of the game at 37-36.

ASU answered Muhammad’s explosive play with another field goal after failing to score a touchdown again in the red zone. Although the Sun Devils were putting up points on the board, they could not afford to keep settling for three while Goff was having a career game.

“(The defense) gave up some yards,” Dykes said. “But when we needed to get a stop, they figured out a way to do it.”

But the Sun Devils would finally get their touchdown. After Goff threw his fifth touchdown pass of the night to wide receiver Darius Powe to give Cal a 45-39 lead with about six minutes to go in the half, ASU was finally able to put together a touchdown-scoring drive. Highlighted by a 42-yard pass from Bercovici to Lucien, the Sun Devils once again worked their way to the red zone, but down six, a field goal wasn’t an option anymore.

At the 4-yard line, Bercovici threw a pass behind the end zone to tight end Raymond Epps. Shaking off cornerback Cedric Dozier, Epps walked into the end zone to give ASU its first touchdown of the second half and give the Sun Devils a 46-45 lead with 2:35 left.

Ever since the third quarter started, ASU had no way of slowing down Goff and the offense. And that did not change on the last drive, when Goff, unfazed by the Sun Devils’ blitzes, dissected the ASU secondary.

“I don’t know if (Goff’s) coming back next year, but if that’s his last game at Memorial Stadium, he sure went out with a bang,” said wide receiver Bryce Treggs. “He’s doing stuff that I didn’t even know he could do. We always say he’s the most unathletic dude on the team, but he was actually kind of athletic today.”

Unfortunately for the Sun Devils, Saturday was a night when the Bears finally had all aspects of their team excelling at the same time. For most of the season, it has usually been the offense picking up the defense or the other way around. But during the last 30 minutes against ASU, Cal found a way to play at a high level on both sides of the field.

“It doesn’t really get much better than that,” Goff said. “This will be one I’ll remember for the rest of my life.”

Ritchie Lee covers football. Contact him at [email protected].