TUCSON, Ariz. -- A momentum-swinging game hanging in the balance, Oregon State coach Mike Riley pulled out a play he had been saving all game.

So what if he would have liked more space to run it. This was the time to do -- and it couldn't have worked out any better.

Sean Mannion threw for a career-high 433 yards and hit Connor Hamlett on a 9-yard pass with 1:09 left for his third touchdown, lifting No. 18 Oregon State to wild 38-35 win over Arizona Saturday night.

"I had frankly screwed it up; I was going to call it a little earlier," said Riley, who broke Lon Stiner's school record with his 75th career win at Oregon State. "I was saving that play and wanted it out a little higher, but then we had a good gain. We called it anyway and it came out differently than it ever has, but that's the way we want it right there."

The Beavers sure needed it.

Oregon State (3-0, 1-1 Pac-12) took a 17-0 lead, Arizona charged back and the teams traded scores in the second half of a game filled with big plays and 1,158 yards of combined offense.

Arizona (3-2, 0-1 Pac-12) landed a big blow in the can-you-top this second half, going up 35-31 with 5:34 left when Matt Scott hit Austin Hill on a 7-yard touchdown.

The problem was that it left too much time for Mannion.

Knowing his team had moved the ball all game against the Wildcats, the calm-and-cool sophomore guided the Beavers 75 yards down the field in 10 plays. Facing a third-and-5 with just over a minute left, Mannion called out a play that sent one receiver into the left flat and Hamlett down the sideline. Arizona's defenders followed the receiver in the flat and Mannion whipped a pass to Hamlet, who slipped just inside the pylon for the winning score.