TUCSON, Ariz. (AP) — 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 nine-yard pass with 1:09 left for his third touchdown, lifting No. 18 Oregon State to a 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, 2-0 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-2 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 seven-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 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.

Mannion finished 29-of 45-for the fifth-most passing yards in school history while setting a career high for the second week. He hit Markus Wheaton 10 times for 166 yards and a pair of touchdowns, and Brandin Cooks nine times for 149 yards.

Storm Woods added for 161 yards and a touchdown for the Beavers, off to their first 3-0 start since 2002.

“We’re definitely enjoying this moment,” Woods said. “It took an entire year last year to get where we are today. The sky is the limit for us right now.”

“Arizona’s a great team and they came out guns blazing,” Beavers cornerback Rashaad Reynolds said. “We had to battle the whole game.”

“Losing is losing,” Arizona coach Rich Rodriguez said. “The kids are battling and they’re going to be all right. Just not right now. They had a lot of guys wide open. When we blitzed, we couldn’t get to the quarterback and that makes it really tough on our defensive backs.”