Oregon State outscored Stanford 13-5 in the last 2:18 to claim an 87-80 win at Gill Coliseum on Thursday night.
Jared Cunningham had 17 of his team-high 21 points in the second half for Oregon State (10-16, 5-10 Pac-10), which had lost four straight and 10 of its previous 12.
Calvin Haynes added 14 points and Roberto Nelson 12 points for the Beavers, who shot 32 of 52 from the field after hitting just 36.6 percent of their shots in the previous eight games.
Jeremy Green had 24 points for Stanford (13-14, 6-10), which has now lost four straight.
The lead was traded three times in the last five minutes before Cunningham's three-point play with 1:29 left put the Beavers ahead for good at 80-77. After a Stanford miss, Oregon State's Devon Collier scored after grabbing an offensive rebound.
Cunningham and Haynes had dunks off Collier assists in the closing seconds to ice the game.