BERKELEY (CBS/AP) — Jared Goff got off to a shaky start and still threw for 390 yards and four touchdowns to lead No. 24 California to a 34-28 victory over Washington State on Saturday in the Golden Bears’ first game as a ranked team in six years.

Goff threw an early interception and was off target on a few throws before finding his groove. He threw two TD passes in a span of less than 2 minutes late in the third quarter surrounding a successful onside kick to erase an eight-point deficit and lead the Bears (5-0, 2-0 Pac-12) to their best start since 2007.

READ MORE: UPDATE: State Attorney General Opens Civil Rights Investigation into Santa Clara County Sheriff's Office

Luke Falk threw two touchdown passes and ran for another score for the Cougars (2-2, 0-1), who have lost 28 of their past 28 games against ranked opponents.

Washington State was in position to reverse that trend after Falk threw a 4-yard TD pass to Gabe Marks midway through the third quarter and Kenny Lawler lost a fumble on Cal’s ensuing possession.

Stefan McClure then changed the tide on a safety blitz that gave Cal one of its seven sacks on the day. Erik Powell then missed a 40-yard field goal wide right and Goff took over from there.

He drove Cal 77 yards to a score on a 20-yard touchdown pass to Kenny Lawler that made it 28-26.

The Bears then surprised the Cougars with an onside kick recovered by Darius Powe. Four plays later, Maurice Harris took a short pass from Goff and ran 24 yards for the score that gave the Bears their first lead of the game. Goff completed a 2-point conversion pass to Bryce Treggs to make it 34-28.

READ MORE: As 49ers and Packers Face Off in the Playoffs, Rodgers Snub Comes Up Again

McClure’s sack was one of two momentum-changing plays he made in the quarter. Washington State tried a fake punt on the opening drive of the quarter only to have punter Zach Charme fumble. McClure scooped up the ball and ran 45 yards for the touchdown.

Cal needed another big play from its defense after the Bears were stopped on fourth down at the Cougars 38 with 4:38 to go. Damariay Drew delivered with an interception and Goff converted two third downs to run out all but the final 12 seconds of the game.

After winning just six games in coach Sonny Dykes’ first two seasons, Cal has matched its best start since 1950 in Dykes’ third year. The Bears need just one more win to be bowl eligible for the first time since 2011 and are in position to contend in the Pac-12 North.

But the schedule gets much tougher from here with road games against No. 10 Utah and No. 7 UCLA, followed by a home game against No. 17 Southern California and a trip to Oregon.

Cal was stopped twice on fourth down in the first half and Goff threw an interception on the third play from scrimmage as Washington State broke out to a 21-7 lead.

MORE NEWS: Man Stabbed In San Francisco Bayview District

Goff then threw his first of two TD passes to Lawler late in the second quarter to start the comeback.

© Copyright 2015 The Associated Press. All Rights Reserved. This material may not be published, broadcast, rewritten or redistributed.