AMES, Iowa (AP) — A little craziness helped No. 20 Kansas State survive an upset bid by Iowa State, 10-9, on Saturday night.

Adrian Martinez passed for 246 yards and rushed for 77, helping the Wildcats improve to 5-1 overall and 3-0 in the Big 12.

Chris Tennant kicked a 30-yard field goal with 7:14 left in the fourth quarter to provide the winning margin.

“Playing football is crazy,” Kansas State receiver Phillip Brooks said. “You never know when your opportunity is.”

Brooks finished with 119 yards on four receptions, and Malik Knowles made five catches for 108.

The Kansas State duo also accounted for two of the game’s defining plays.

The Wildcats scored when Martinez ducked under a potential sack, then heaved the ball to a leaping Brooks, who maintained his balance and raced downfield for an 81-yard touchdown.

“Going into the route, I got knocked over,” Brooks said. “I caught it, turned and got hit. I was making sure I stayed up.”

In the second quarter, Martinez found Malik Knowles for a 68-yard gain. But Knowles fumbled before crossing the goal line. Iowa State’s Anthony Johnson punched the ball out and Colby Reeder recovered in the end zone.

“Their kid made a great play on Malik,” Wildcats coach Chris Klieman said. “He made a phenomenal play. Touchdowns and points were going to be at a premium, with two good defenses.”

Martinez finished 12-of-19 passing and rushed 19 times.

“For him, the big key was not to turn the ball over,” Klieman said. “Boy, he doesn’t panic. He does such a good job of being calm and relaxed.”

The Cyclone (3-3, 0-3) have scored just one touchdown in their last 20 possessions.

“I thought we had a good plan coming in,” Iowa State coach Matt Campbell said. “Obviously, the inconsistency of that plan continues to show up.”

The loss snapped Iowa State’s six-game home winning streak in night games. A crowd of 60,561 packed Jack Trice Stadium, the largest crowd to attend a matchup between the Cyclones and Wildcats.

“I know it’s hard to win here,” Klieman said. “I’ve been here enough.”

Jace Gilbert made three field goals to give Iowa State a 9-7 lead entering the fourth quarter. Gilbert missed three times a week earlier at Kansas, including a potential game-tying kink in the closing seconds.

“Just young players that are playing inconsistently,” Campbell said. “You still see ‘A’ players making ‘A’ plays, but we’re not as consistent as we need to be to win football games right now.”

For the Wildcats, it was their fewest points scored in a conference road win since 1982.

Brooks and Knowles were the first Kansas State receiving tandem to each go over 100 yards in a Big 12 game since 2014.

TAKEAWAY

Kansas State QB Adrian Martinez relied more on his passing against Iowa State, after running wild the last two weeks. Martinez rushed for a total of 319 yards and seven touchdowns against Oklahoma and Texas Tech, but netted just 34 yards on the ground during the first half Saturday. Duece Vaughn, who was averaging 117 rushing yards per game, ran for just 10 yards in the first 30 minutes, and only 23 yards in the game.

POLL IMPLICATIONS

Kansas State should remain in the Top 25 for a third straight week and climb inside the top 20, after rival Kansas’ loss to Texas Christian earlier Saturday.

UP NEXT

Kansas State is off this weekend, before traveling to No. 17 Texas Christian for a game Oct. 22.

Iowa State visits Texas on Saturday.