STANFORD, Calif. (AP) -- Oregon State's best chance at a Pac-12 title and possibly a Rose Bowl berth seemed well within its grasp.

In an instant, all those dreams slipped away.

Cody Vaz threw for 226 yards and a touchdown and had an otherwise solid start washed away with a fourth quarter fumble, and No. 13 Oregon State lost 27-23 on Saturday to drop back in the conference chase.

"We're disappointed, obviously," Oregon State coach Mike Riley said. "It was a tough loss and we had our opportunities. What we did was give up the big play two scores up and gave them back the momentum. That was big for them. Then the turnover gave them good field position to score the winning touchdown."

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.

Kevin Hogan audibled out of a run and called the play "Special," which Stanford also ran to convert a fourth-and-9 in an overtime win against Arizona earlier this season, then hit tight end Zach Ertz for a 13-yard touchdown for the go-ahead score with 5:07 left and Stanford stopped the Beavers twice more.

Now it's the Cardinal who head to second-ranked Oregon next in what is essentially a North Division final - if Stanford also beats UCLA in its season finale - for a spot in the conference championship game. Oregon has beaten Stanford the last two seasons.

"No disrespect to them, that's a great team," said Oregon State's Storm Woods, who ran for 94 yards. "But we beat ourselves."

Oregon State won the turnover margin 4-1 but only converted 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 caught the go-ahead touchdown, Oregon State got the ball back and Debniak sacked Vaz on third down.

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

Hogan, who took over the starting role from inconsistent Josh Nunes, completed 22 of 29 passes with two interceptions. He also ran for 49 yards on 11 carries.

Vaz finished 23-of-38 passing in a deflating loss for Oregon State, which rallied from a 14-0 deficit to score 23 straight points and controlled the pace for most of the game.

The Beavers haven't played in the Rose Bowl since 1965, and had a chance to get there without even winning the Pac-12. But with three loses, that chances are slim at best.

Stanford started strong and closed fast.

After Ertz fumbled on Stanford's opening possession, the defense stopped Oregon State three-and-out. Then Hogan led a 13-play, 93-yard scoring drive - its longest of the season - capped by Stepfan Taylor's 1-yard touchdown run.

Hogan kept the momentum going, rolling to his right and hitting fullback Ryan Hewitt on a play-action pass. Hewitt sliced back inside and bulldozed through a defender for a 12-yard TD that gave Stanford a 14-0 lead late in the first quarter.

The Beavers came back in a hurry.

They used three different running backs on an 81-yard drive that came almost exclusively on the ground. Terron Ward finished it off when he ran for a 7-yard score to the Beavers on the board, and Trevor Romaine kicked the first of his three field goals to slice Stanford's lead to 14-10 in the second quarter.

In the final minutes of the first half, Tyrequek Zimmerman stripped Taylor - who ran for 114 yards and a touchdown, eclipsing 1,000 yards rushing for the third straight season - at the Oregon State 21. That ended a streak of 262 rushes for Taylor without a fumble.

Oregon State converted two long third down on the opening possession of the third quarter. None better than when Vaz found Markus Wheaton on a short screen pass over the middle on third-and-16 for a 22-yard touchdown to give the Beavers a 17-14 lead.

Rudolf Fujita tipped Hogan's pass that Feti Taumoepeau intercepted. Stanford's defense held Oregon State to a 42-yard field goal by Romaine, who made another from 44 yards later in the third quarter for a 23-14 lead.

The momentum changed for good on one play.

Taylor took a short pass from Hogan while the quarterback was being tackled. Taylor made a defender miss down the sideline, cut back inside and stiff-armed another to the ground for a 40-yard TD that trimmed Oregon State's lead to 23-21 as the third quarter expired, a play Stanford coach David Shaw called the best of Taylor's career.

Rashaad Reynolds out jumped Jamal-Rashad Patterson to intercept Hogan's pass midway through the fourth. Two plays later, Vaz fumbled, and Stanford surged back to squeak out a far-from-perfect victory.