Stanford's Ryan Hewitt, left, scores a touchdown and is copied by Zach Ertz, minus the football.

STANFORD, Calif. - Kevin Hogan threw for 254 yards and three touchdowns in his first collegiate start, and No. 16 Stanford overcame four turnovers to rally past No. 13 Oregon State 27-23 on Saturday and stay in control of its Pac-12 title hopes.

Cody Vaz fumbled late in the fourth quarter to give the Cardinal (8-2, 6-1) the ball at the Beavers' 29. The only Oregon State (7-2, 5-2) turnover turned out to be the difference.

Hogan hit tight end Zach Ertz for a 13-yard go-ahead touchdown and the Cardinal stopped the Beavers twice more. Stanford will head to second-ranked Oregon next week with a chance to take over sole control of the North Division and move closer to a spot in the conference championship game.

Oregon State won the turnover margin 4-1 but got just three points out of them - and the one mistake cost the Beavers badly.

Vaz fumbled while shifting the ball during a scramble and Josh Mauro recovered. After Ertz's go-ahead score, Oregon State got the ball back and Alex Debniak sacked Vaz on third down.

The quarterback left with an injury, and Sean Mannion - the former starter - threw incomplete on fourth-and-16 from the Oregon State 37 with 1:52 left.