SAN ANTONIO (AP) Gardner Minshew II and that glorious mustache conjured up a final bit of magic in a grand finale for Washington State.

The graduate transfer quarterback whose whiskered upper lip was loved and mimicked by Cougars fans all season, threw two touchdown passes and ran for another score in sending No. 12 Washington State to a 28-26 win over No. 25 Iowa State in the Alamo Bowl on Friday night.

Minshew's passing and scrambling earned the Cougars (11-2) a school record for wins in a season.

He threw for 299 yards, none of them bigger than a play made out of desperation when Iowa State had all the momentum.

After watching a 21-10 lead dwindle to 21-20 by early in the fourth quarter, the Cougars stripped the ball from Iowa State running back David Montgomery at the Cyclones' 30. Minshew, who had been held in check in the third quarter, escaped a third-down pass rush to flip a last-second shovel pass to Tay Martin that went for 20 yards.

The play stunned the Cyclones, and Max Borghi scored on a 10-yard run the next play.

It was just another big fourth-quarter moment for the transfer from East Carolina who coach Mike Leach had lured out West with the promise he could lead the nation in passing.

Minshew was the nation's leading passer in yards per game this season and won the Johnny Unitas Award as the nation's top senior quarterback in a season the Cougars fell one game short of playing for the Pac-12 championship.

Nearly all of his completions this season were more orthodox than the flip to Martin. None were bigger for the season and the legacy it set for the program.

''I want to say thank you to these coaches, this university and these fans for taking me in,'' Minshew said.

''So glad to be a part of this,'' he said. ''One thing I've always been told is to leave a place better than we found it. This place could be really special.''

The Cyclones did a good job in bottling him up for much of the game. Iowa State's defense held Washington State 10 points and 135 yards below their season averages and two of the Cougars' touchdowns came on short drives after turnovers.

But after Minshew found a way to get Washington State in the end zone, the Cougars' defense made the one play it had to at the end.

Iowa State's last chance came after quarterback Brock Purdy scored from a yard out with 4:02 left. The Cyclones went for two, but a pass to Montgomery was stopped well short of the goal line after a false-start penalty pushed the line of scrimmage back to the 8.

Iowa State had seven false start penalties and had two players ejected for targeting hits on Minshew.

Purdy passed for 315 yards and Cyclones receiver Hakeem Butler caught nine passes for 192 yards, six yards shy of the Alamo Bowl record. Montgomery rushed for 124 yards.

The Cyclones (8-5) had rallied from a 1-3 start to finish third in the Big 12, the program's best conference finish in 40 years.

''This team never quits, plays with elite attitude and elite effort. The missing piece for us right now is in the detail,'' Iowa State coach Matt Campbell said. ''Now, to take the next step in this program, is detail. It's what got us tonight. Silly mistakes.''

THE TAKEAWAY

Washington State: Minshew survived several tough hits in the first half, then was excellent when it was time to kill the clock. He completed 9 of 13 passes in the fourth quarter for 78 yards. After Iowa State's final touchdown, he completed three passes, two of them converting third downs, as the Cougars ran out the clock.

Iowa State: Turnovers and targeting calls were critical. Purdy threw two first-quarter interceptions and Montgomery's fumble was a game-changer. Iowa State had two key defenders ejected in the second quarter for targeting hits to Minshew. Senior linebacker Willie Harvey was ejected after smashing Minshew in the facemask on a scramble. Defensive end Enyi Uzwazike was booted after a sack knocked Minshew's helmet off.

TOUCHDOWN TAUNTING

Washington State cornerback Marcus Strong had a long touchdown interception return wiped out in the first quarter when he was flagged for taunting on his way into the endzone. Strong stepped in front of a pass intended for Butler and had a clear path to the goal line. He was penalized because he held the ball out and looked back as Purdy made a futile dive for his feet. Instead of the score, the Cougars got the ball on the Iowa State 20 and scored two plays later when Minshew connected with Renard Bell.

UP NEXT

Washington State: Leach has to find another big-armed quarterback to be among the nation's passing leaders in 2019. Do that and the Cougars should be among the Pac-12 favorites as they return 14 starters on offense and defense, plus their kicking specialists.

Iowa State: The Cyclones were in the mix for a Big 12 title-game berth late in the season and will expect to again in 2019 with Purdy leading an experienced lineup that loses only five senior starters. The key will be the NFL draft options for 1,000-yard rusher Montgomery and 1,000-yard receiver Butler.

---

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

Copyright 2018 by AP. Any commercial use or distribution without the express written consent of AP is strictly prohibited.