AMES, Iowa -- For Iowa State, it felt like yet another inexplicable loss to Kansas State might be inevitable.
Then a fumble flipped in the air and fell right into Mike Rose's hands, and the Cyclones' bad luck against the Wildcats seemed to wash away.
David Montgomery ran for three touchdowns, including the winner with 4:34 to go, and 25th-ranked Iowa State rallied from 17 down in the fourth quarter to stun Kansas State 42-38 and snap a 10-game skid against the Wildcats on Saturday night.
Montgomery had 149 yards rushing for the Cyclones (7-4, 6-3 Big 12), who clinched their best-ever finish in the Big 12.
The made a stop, and Montgomery's 18-yard touchdown run gave Iowa State an improbable lead.
"This team has never disappointed me," Iowa State coach Matt Campbell said. "We're not flashy. We're not pretty. But you better not count us out."
Kansas State's (5-7, 3-6) fate was sealed when a long pass to Dalton Schoen deep in Iowa State territory glanced off his fingertips with 1:20 left.
The Wildcats took control by going 92 yards on eight plays after picking off Purdy, opening up a 31-21 lead on Skylar Thompson's 9-yard TD pass to Chabastin Taylor late in the third. K-State's Kevion McGee then intercepted Purdy again, and Isaiah Zuber's second TD grab of the game made it 38-21 early in the fourth.
Purdy redeemed himself down the stretch though, finishing with 337 yards passing and two touchdowns in what Campbell said was his best game yet.
Thompson threw three touchdown passes and ran for a score, and Alex Barnes rushed for 184 yards and a TD for the Wildcats. Barnes rushed for at least 100 yards in his last four games, the longest such streak for a Wildcat since Darren Sproles had a five-game streak in 2003.
"I've never lost a ballgame that way. I'll have to dissect it," Kansas State coach Bill Snyder said. "I can't tell you what my feelings are right now."
Iowa State: The Cyclones revival since the start of last season had been sparked by their defense. But the cracks that began to show in a win over Baylor and a loss at Texas developed into sink holes against the Wildcats. Iowa State's offense, bailed out so often by their teammates on the other side of the ball, finally returned the favor -- and the defense showed up when it mattered.
K-State: If this proves to be Bill Snyder's final game, what a brutal way to go out. All the Wildcats had to do was protect a 17-point lead with 12 minutes to go bowling, but they couldn't do it.
K-State's 5-7 record is the worst since Snyder came back in 2009. Speculation has been rampant that the 79-year-old Snyder might step down, but he didn't address those rumors after the game. "That's the last thing on my mind right now," Snyder said when asked about his status.
WHY THE CYCLONES FELL BEHIND
Tarique Milton fumbled away a punt just before halftime, and it took the Wildcats 16 seconds to go 34 yards for a touchdown; a 6-yard pass from Thompson to Isaiah Zuber to make it 21-14. Kansas State, which struggled in the red zone all year, scored on all six of its trips inside Iowa State's 20.
DID THE BUTLER DO IT?
On the previous series, Iowa State appeared to take a 20-14 lead on a short TD pass from Purdy to Milton. But Hakeem Butler was called for offensive pass interference, and Connor Assalley then shanked a 38-yard field goal attempt. Butler also had a sure TD bounce off his hands late in the fourth quarter, but Montgomery bailed him out shortly thereafter. "David is the best player in the country to me," Butler said. "I tell him that every day, and he proved that." Butler finished with 144 yards on five catches.
HE SAID IT
"The chances of the ball just falling right in his lap like that and then returning it for a touchdown and quick scores like that after we were up 17 points, that was frustrating. We couldn't really get it going after that," Thompson said about Rose's fumble return.
Iowa State hosts Drake of the FCS in a makeup for its canceled opener.
Kansas State's season is complete.
More AP college football: https://apnews.com/Collegefootball and https://twitter.com/AP-Top25
Is Hockenson the next Gronk?
Iowa's T.J. Hockenson is considered one of the most complete TEs in the draft and is often compared to Rob Gronkowski in terms of his playing style.
College football game to circle now for each Top 25 team
From a Clemson-Texas A&M rematch to another round of Georgia-Notre Dame, these are the top games we're already looking forward to.
Two Georgia players arrested after bar fight
Senior wide receiver Tyler Simmons and freshman cornerback Tyrique Stevenson are facing misdemeanor charges related to the incident.
Successful showing at Kentucky's Pro Day
SEC Now analysts Matt Stinchcomb and Gene Chizik examine how far Kentucky has come as a program and who can make an impact in the NFL for the Wildcats.
White, Williams checking off boxes at LSU's Pro Day
SEC Now discusses the potential of linebacker Devin White and cornerback Greedy Williams at the next level.
Georgia Tech D-lineman Adams dies at age 21
Georgia Tech defensive lineman Brandon Adams has died at age 21, the school announced.