BOISE, Idaho (AP) Boise State quarterback Brett Rypien etched his name in the Mountain West record books as the conference's all-time leading passer in both yards and completions. But the pro-style passer needed his feet almost as much as his arm to beat the nation's second-best scoring defense.

Rypien engineered a fourth-quarter comeback, finishing with 269 yards passing with a touchdown and one interception, along with 30 yards rushing on eight carries that included scrambles for three first downs, in leading Boise State to a 24-17 upset over No. 16 Fresno State on Friday night.

''(Rypien) ran the ball well tonight,'' Boise State coach Bryan Harsin said. ''He moved and scrambled and all those little plays, they don't seem like much at the time but they add up throughout the game. And that's why we won the game tonight.''

Trailing 17-10 late in the third quarter, Rypien scrambled on third down for a 10-yard gain to set up a game-tying 1-yard run by Alexander Mattison.

After the game, Rypien shrugged off his fleet-footed prowess.

''It's just me trying to make a play,'' Rypien said. ''There were some third-down situations in there where I felt like their eyes were off me and I had to take off and make a play.''

Even Fresno State coach Jeff Tedford could only shake his head afterward when recalling Rypien's running plays.

''They have a good offense and Rypien killed us with his legs a little,'' Tedford said.

Rypien's legs complemented his clutch throws, none bigger than a 49-yard scoring strike on another third down play when he hit Khalil Shakir in stride with 9:22 remaining in the fourth quarter to give the Broncos a 24-17 lead.

''On the touchdown pass, (Rypien) stepped up and slid and delivered a perfect ball in that situation,'' Harsin said. ''With all that was going on, when you can deliver a perfect throw in that moment in a tight ball game - it takes a lot of hard work for that guy to do that.''

Boise State (8-2, 5-1 Mountain West), which hasn't lost to Fresno State at home since 1984, beat a ranked team for the first time in November in program history to keep its conference title aspirations alive.

It was also the first time since 1999 that the Broncos were an underdog at home for a regular season game.

''We knew it was going to be tough,'' Rypien said. ''Being an underdog on the blue, that's never a good feeling, especially since we haven't been in a long time. And some guys in the locker room took that kind of personally.''

Mattison rushed for 144 yards on 30 carries and two touchdowns, the most any single running back has tallied against the Bulldogs' this season.

Fresno State (8-2, 5-1) had only given up three touchdowns in conference play before facing the Broncos and had only been in one game decided by one score or less all season.

Following another bitter loss to the Broncos, Tedford remained upbeat.

''We'll bounce back,'' Tedford said. ''Our guys played hard right down to the end. I've still got a lot of confidence in this team.''

Fresno State Marcus McMaryion, who struggled against Boise State in the Mountain West title game last December, was 24-of-35 passing with a touchdown. However, McMaryion couldn't pull off any late-game heroics after the Bulldogs fell behind, as the Broncos held Fresno State on its final two drives before running out the clock to secure the victory.

THE TAKEAWAY

Fresno State: The Bulldogs' faint hopes to emerge from the Group of 5 and earn a berth in a New Year's Six bowl dimmed with the loss. However, they still have a chance to win the West division and get back to the conference title game.

Boise State: With the season hanging in the balance, the Broncos showed they have the fortitude to do what it takes to win close games for the second straight week. The Broncos still have plenty of work to do in order to get an opportunity to defend their conference title, including a home date in two weeks against Mountain division leader No. 14 Utah State.

POLL IMPLICATIONS

Fresno State will fall after the close loss on the road, but not far enough to drop out of the poll altogether. Boise State, which hasn't been ranked since the third week of the season, might have a chance to crack the top 25 again with some help on Saturday.

UP NEXT

Fresno State: The Bulldogs return home Saturday to face San Diego State with a berth in the conference title game on the line.

Boise State: The Broncos will travel to New Mexico on Friday.

---

More AP college football: https://apnews.com/tag/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.