CORVALLIS, Ore. >> Kevin Hogan played on a bum ankle, the running game churned against a porous defense, and Stanford jumped into advantageous position in the league race — all on an eventful Friday night under the lights.

Fueled by deep passes, big runs and a defense that tightened in the second half, the Cardinal rolled to a 42-24 win over Oregon State, its third victory in a row after the ugly Week 1 loss at Northwestern.

Stanford (3-1, 2-0) is atop the Pac-12 North with two road wins and a home-heavy schedule over the next two months. In fact, its only remaining trips are to Washington State and Colorado — hardly daunting challenges.

The big pass came courtesy of Hogan, who hobbled around on his sprained left ankle but was plenty good enough. The fifth-year senior attempted just 13 passes through three quarters and completed nine, including a 49-yard rocket to receiver Michael Rector for a touchdown that gave Stanford control of what had been a back-and-forth game.

The Cardinal’s ground game took over from there and finished with more than 300 yards against an OSU defense that struggled with the basics. Most of the production came from tailback Christian McCaffrey — but not all. Barry Sanders uncorked a 65-yard touchdown run in the fourth quarter.

But the victory wasn’t easy, and it wasn’t without a cost. Two starting defensive linemen, Aziz Shittu and Brennan Scarlett, were unable to finish the game because of injuries. The exact nature and severity was not immediate disclosed, but it’s the most vulnerable unit on the team, one that has already lost nose tackle Harrison Phillips for the season.

Hogan was injured in the third quarter of the victory at USC and did not participate in practice until Thursday. But he passed the most important test: warmups.

“It’s just physical: If he can do it, he’ll play,’’ Stanford coach David Shaw said earlier in the week. “And it might be a combination of where he can play and not do everything. We’ll see how it goes.’’

Stanford got exactly the start it wanted, with McCaffrey plowing through the Beavers repeatedly on a 63-yard scoring drive. (Hogan completed his only pass on the drive, 12 yards to Devon Cajuste.) Then the Cardinal defense did its share, stopping Oregon State on three downs.

A turnover flipped the momentum, as Hogan’s rocket bounced off receiver Trent Irwin and into the arms of OSU’s Cyril Noland-Lewis near midfield.

The Beavers wasted no time taking advantage, producing an impressive, high-speed touchdown drive akin to those USC unleashed on Stanford in the first half last week.

The teams traded touchdowns. Hogan hit tight end Austin Hooper on a 42-yard strike that gave the Cardinal a seven-point lead. Then Ryan Nall rumbled in for the Beavers to erase the deficit.

The defenses settled in, but only for two possessions. Stanford regained the lead on a 70-yard touchdown drive aided by a favorable spot on Remound Wright’s third-down plunge. On the next play, Hogan hit McCaffrey crossing from right to left, and the tailback darted through OSU’s secondary for a 38-yard gain. Wright eventually bounced off two tacklers and scored to give the Cardinal a 21-14 edge.

OSU closed the first-half scoring with a short field goal after Stanford’s defense held on third down from the 6.

The Cardinal missed an ideal chance to take control early in the third quarter, after Oregon State fumbled at its 9. But Stanford couldn’t find the end zone, and Conrad Ukropina missed a short field goal.

The next possession was more productive. On second down, Hogan fired a pass to receiver Rector deep down the right sideline. The ball was thrown slightly behind Rector and to the outside, somehow eluding two OSU defenders. Rector made a twisting catch and raced the short distance into the end zone for a 28-17 lead.

Sanders added to the lead with an 11-yard touchdown run later in the quarter. Sanders then broke loose for a 65-yard touchdown run in the fourth quarter.