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
NC State's Des Kitchings, George McDonald to fill co-coordinator roles
North Carolina State has named assistants Des Kitchings and George McDonald as co-offensive coordinators.
Ranking every starting QB in a bowl game by NFL draft prospects
Clemson's Trevor Lawrence is the top draft prospect among bowl QBs, even if the NFL must wait a couple of years for him. Where do Kyler Murray and Tua Tagovailoa land?
Hot Board: Last-minute recruiting pitches
With one more weekend to go before the early signing period begins Wednesday, teams are pushing hard for the recruits they want, and oftentimes last impressions are lasting impressions.
College football's best players for 2018 season
Oklahoma teammates Kyler Murray and Marquise Brown make the top 25 of the postseason top-50 ranking.
Christion launches a 52-yard TD to Johnson
South Dakota State's Taryn Christion leaves the pocket and lets it rip to Cade Johnson for a 52-yard touchdown.
Anderson turns on the jets for a 41-yard TD
North Dakota State's Bruce Anderson breaks a tackle and takes it to the house for a 41-yard touchdown and 35-14 lead.