Daniel Lasco rushed for a career-high 188 yards on 30 carries and scored on touchdown runs of 14, 21 and 15 yards to help the Bears (5-4, 3-4 Pac-12) snap a three-game losing streak and move within a game of becoming bowl eligible.
The comeback spoiled a record-setting performance for Oregon State's Sean Mannion, who completed 30 of 45 passes for 320 yards and became the Pac-12's all-time passing leader.
Mannion, who entered the game needing 194 yards to break former USC quarterback Matt Barkley's record of 12,327 yard, completed passes to seven different receivers, but the Beavers (4-4, 1-4) suffered their third consecutive loss.
The Bears came into game ranked fourth in the nation in passing yards, averaging 371.5 yards a game, but kept OSU off balance with a running game that racked up a season-high 269 yards on 47 carries.
Goff completed 24 of 47 passes for 277 yards, marking the first time in seven games that he had thrown for fewer than 300 yards.
Trailing 27-10 in the third quarter, Mannion guided Oregon State on three consecutive touchdown drives, taking a 31-27 lead on Terron Ward's 16-yard run with 12:02 to play.
Following Harper's touchdown, Oregon State's bid to reclaim the lead ended when Caleb Coleman intercepted a Mannion pass at the Beavers' 29 with 7:48 to play, setting up a 47-yard James Langford field goal.
The Oregon State offense sputtered in the first quarter as the Beavers ran 14 plays that netted 70 yards and as many punts (three) as first downs and they crossed midfield for the first time when Storm Woods broke a 49-yard run on the first play of the second quarter that took the ball to the 3.
Mannion then hit tight end Rahmel Dockery slanting right to left with a 3-yard touchdown pass to take 7-3 lead.
Cal responded with a 10-play, 75-yard scoring drive, capped by Daniel Lasco's 14-yard run over left tackle with 10:05 remaining in the half.
Three of Oregon State's four remaining regular-season games are at home, including next week's game against Washington State.