STANFORD, Calif. (AP) With star quarterback K.J. Costello knocked out of the season opener, No. 25 Stanford had to rely on its defense and running game to get the win in the season opener.

Costello threw a 2-yard touchdown pass before getting hurt on a late hit and the Cardinal used four turnovers and an improved running game to hold off injury plagued Northwestern 17-7 on Saturday.

''It's what you want as a coach,'' Stanford's David Shaw said. ''When things are difficult, I don't have to turn into Knute Rockne. I don't have to do all the talking. ... There's no sense of panic. There's a sense of we haven't played well enough and they're still in the game so we have to play better.''

Cameron Scarlett ran for 97 yards and a key first down late that helped run out most of the clock and then Casey Toohill helped seal the win for the Cardinal (1-0) with a strip sack of Hunter Johnson that led to a fumble recovery in the end zone by Jordan Fox with 20 seconds left.

Stanford had forced a punt by Northwestern on the previous drive to preserve a three-point lead.

''That's what you live for,'' Toohill said. ''That's the icing on the cake. You want to be out there and you want to make a play. There are so few times in your life when you get that adrenaline rush with the game on the line and you have to do your job.''

Costello completed 16 of 20 passes for 152 yards and the TD pass to Michael Wilson that capped a 90-yard drive in the second quarter for the Cardinal (1-0). But his day ended early when he was hit with a forearm to the facemask while sliding on a scramble by Earnest Brown IV with just 2 seconds remaining in the first half.

Brown was called for a late hit that set up Jet Toner's 51-yard field goal but wasn't ejected for targeting. Costello stayed down on the turf for a few minutes before being helped to the locker room. He didn't return to the game.

Shaw said he didn't see the play and had no update on Costello's condition.

Northwestern also lost a quarterback with TJ Green leaving with a foot injury in the third quarter after being sacked and losing a fumble on a play in the red zone. Green was undergoing surgery at Stanford Hospital.

He had replaced the ineffective former Clemson five-star recruit Hunter Johnson late in the first half. Johnson came back in to finish and went 6 for 17 for 55 yards and two interceptions. He also lost a fumble that Stanford's Jordan Fox recovered in the end zone for a touchdown that sealed the game with 20 seconds remaining.

''I saw a freshman quarterback in his first start who did everything in his power to prepare himself to play,'' coach Pat Fitzgerald said. ''He has to get a lot better and he will get better. He'll work on it. I have great confidence in him.''

Things were so bad for the Wildcats that they failed to score after Stanford backup quarterback Davis Mills lost a fumble that Greg Newsome returned to the 21. Northwestern gained 1 yard on three plays before Charlie Kuhbander missed wide right on a 38-yard field goal try.

The Wildcats finally got on the board on a 1-yard run by John Moten IV midway through the fourth quarter.

THE TAKEAWAY

Northwestern: Fitzgerald kept the starting quarterback secret until just before game time, not that it helped much. Johnson threw an incompletion on his first pass, was intercepted on a ricochet on his second throw and was 1 for 4 for 3 yards and an interception on his first three drives. Green entered on the fourth drive and led the Wildcats into Stanford field position for the first time before that stalled with an incompletion on fourth-and-6 from the 34. It only got slightly better in the second half but Northwestern also lost running back Isaiah Bowers to a lower-body injury.

Stanford: The Cardinal came into the season relying heavily on Costello to lead the offense and when he went down things stalled a bit. An interception in Northwestern territory by Paulson Adebo led to no points when Toner hit the upright on a 29-yard attempt and Mills missed several open receivers and lost two fumbles. He finished 7 for 14 for 81 yards. The Cardinal also lost star left tackle Walker Little to an apparent leg injury late in the game and there was no update on his condition.

UP NEXT

Northwestern: Hosts UNLV on Sept. 14.

Stanford: Visits Southern California next Saturday.

---

More AP college football: https://apnews.com/Collegefootball and https://twitter.com/AP-Top25

Copyright 2019 by STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.