STANFORD, Calif. — As Stanford’s offense sputtered in the second half, Christian McCaffrey kept urging his teammates on that the offense could be better. Then he finally took matters into his own hands and iced away another win.

McCaffrey scored his second touchdown on a late 41-yard run that helped lead No. 8 Stanford to a 26-13 victory over Kansas State on Friday night in the season opener for both teams.

Stanford had just 30 yards in the second half before McCaffrey’s long touchdown run following a failed onside kick by Kansas State put the game away.

“By nature, he’s not a patient human being. He wants everything to be perfect,” coach David Shaw said. “Like many players, he drives himself and he drives his teammates. At the end of the game, he kept saying it, ‘We’re so much better than this. We’re so much better.’ It’s not about his yards, not about his carries, it’s about our machine when we’re humming.”

After a fast start led by quarterback Ryan Burns in his first career start, the Cardinal were far from a machine in the second half. With a new quarterback and three new offensive linemen, Stanford struggled to get anything going with a fumble and four punts to start the second half.

But a defense that had eight sacks, one safety and two turnovers made sure it wasn’t an issue.

“The defense bailed us out a lot in the second half,” McCaffrey said. “We just have to be better in a lot of different areas. We have a lot of new guys on this team playing their first college football game. Sometimes that comes back and haunts you, especially Week 1.”

Burns started fast by completing his first 10 passes, including a 40-yard touchdown strike to Michael Rector on the opening play of the second quarter.

McCaffrey then got into the act with an electrifying 35-yard touchdown run. He froze safety Kendall Adams with a juke and raced to the end zone for the score.

“When he touches the ball enough, good things happen,” coach David Shaw said.

McCaffrey shattered Barry Sanders’ 27-year-old record by gaining 3,496 all-purpose yards last season when he finished second to Alabama’s Derrick Henry in the Heisman.

He finished 126 yards on 22 carries and 210 all-purpose yards in the opener this year.

“He had those two big plays,” Kansas State coach Bill Snyder said. “Outside of that I think our guys defended him quite well.”

THE TAKEAWAY

Kansas State: The Wildcats’ inexperienced offensive line featuring two freshmen struggled. Stanford had eight sacks, including one in the end zone by Jordan Watkins for a safety. Jesse Ertz was briefly knocked out of the game in the second half after one hit. He recovered to throw a late TD pass to Isaiah Zuber.

“There was just absolutely no consistency with us offensively,” Snyder said.

Stanford: After converting his first five third-down passes into first downs, Burns struggled. The Cardinal had just one first down in the second half before McCaffrey’s second TD run. The defense was up to the task to make the lead hold but could have more trouble doing that once the Pac-12 schedule starts.

WIPED OFF TD

The biggest highlight might have been a play that didn’t even count. McCaffrey fielded a punt at his own, and made his way through almost the entire Kansas State coverage unit for a 97-yard score. The only problem was an illegal block by Curtis Robinson that wiped it all out and forced Stanford to start a drive on its own 2.

“There is a reason why there are no 97-yard punt returns because you should not catch the ball on the 3-yard line. He knows that,” Shaw said. “But what he did after he caught it, wow, that’s the best punt return that doesn’t count I’ve ever seen.”

UP NEXT

Kansas State: The Wildcats play Florida Atlanta in their home opener Sept. 17.

Stanford: The Cardinal are off before beginning conference play at home against No. 20 USC.

QUOTABLE

“We’ve set the bar for where we are. In two weeks, it has to be higher. I don’t know how high we can get it, but it has to be higher than it was today,” Shaw said.