BERKELEY, Calif. (AP) Having seen his team dominate California all game, Oregon State coach Jonathan Smith felt it was appropriate that linebacker Hamilcar Rashed Jr. put an emphatic stamp on the day with with a game-ending sack.

It was the season-high ninth sack by Smith's defense and helped erase any lingering memories the Beavers had after suffering a 45-point loss one week earlier.

''Overall for our defense to be able to finish it that way was huge,'' Smith said after Oregon State's 21-17 win over California on Saturday. ''We talked about putting the previous game to rest and I thought our guys did it. Had a great week of work, energy and attention to detail, and it played out today.''

B.J. Baylor scored on a 13-yard touchdown run with 4:41 remaining for the game-winning score after Oregon State blew a 14-point lead.

Jake Luton threw a pair of touchdown passes, Artavis Pierce ran for 80 yards to help the Beavers (3-4, 2-2 Pac-12) win for the second time in three games.

''We're not the same Oregon State team as last year,'' said defensive end Jordan Whittley, referring to the Beavers' 49-7 loss to the Golden Bears in 2018. ''Different team.''

Especially on defense.

Rashed had three sacks and four tackles for losses, tied for third-most in school history. Riley Sharp also had three sacks.

''It's the most fun I've ever had,'' Sharp said. ''Because our run defense was really, really good today, in some situations they were forced to pass which allowed us to run some play calls that allowed multiple blitzers coming off the edge and different schemes to help us get to the quarterback.''

The defense helped offset a sporadic day from the Beavers offense.

Oregon State's offense was shut down in the second half until driving 80 yards for the game-winning score. The Beavers converted three third downs on its way to the end zone, the third coming when Baylor bulled his way through the defense and stretched across the goal line to score.

Baylor was initially ruled down short of the end zone until a side official came in and signaled touchdown. The play was reviewed and confirmed.

Jaydon Grant sealed the win with an interception off third-string quarterback Spencer Brasch on Cal's ensuing possession after Devon Modster was taken out for unknown reasons.

Oregon State has won consecutive road games for the first time since 2013.

''We did have the mindset of wanting to come in and attack defensively,'' Smith said. ''These guys bought into the plan that we were going to go into attack mode. We brought some more pressure than we had been doing and guys executed it.''

The Golden Bears (4-3, 1-3) have lost three straight.

Modster was sacked seven times and struggled to throw downfield but connected with Jordan Duncan for a 33-yard touchdown late in the third quarter to put Cal up 17-14.

''We just didn't execute when we needed to,'' Duncan said. ''They made more plays than us, it's simple.''

Modster was 12 of 27 for 151 yards before being taken out midway through the fourth with a lower body injury. Head coach Justin Wilcox said he didn't know the extent of Modster's injury.

''Give Oregon State credit. They have a good offense,'' Wilcox said. ''We need to acknowledge that. But we played really, really poor on three drives. That cost us, big time.''

Luton had an uneven day, going 18 of 34 for 174 yards.

THE TAKEAWAY

Oregon State: The Beavers repeatedly tripped over themselves with foolish penalties and an off day by Isaiah Hodgins but still won on the road. It was a nice bounce back for Smith's team after being smacked by Utah 52-7 the previous week. Pierce's running in the second half provided a big lift.

California: This was a game Bears fans were counting on to get them a step closer to bowl eligibility. Instead, a third straight loss and uncertainty at quarterback have those hopes on hold. The offense was average at best and negated a strong day by the defense. That's been the story for this team for most of the season.

COACHING PENALTY

An unidentified member of Oregon State's coaching staff was called for unsportsmanlike conduct after the Beavers were called for pass interference in the third quarter. Several people on the Oregon State sideline began chirping at officials after the play, which gave Cal a first-and-goal.

''I wasn't certain I was the one to get the call but the way it was going, offense, defense, I figured it was my turn to get a penalty because we were getting them on both sides,'' Smith said.

UP NEXT

Oregon State: The Beavers get a second bye week before playing at Arizona on Nov. 2.

California: Plays at No. 13 Utah next Saturday. The Bears are 1-1 against Top 25 teams this season, beating Washington and losing to Oregon.

--

More AP college football:�https://apnews.com/tag/Collegefootball�and�https://twitter.com/AP-Top25

Copyright 2019 by STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.