LARAMIE, Wyo. (AP) -- Playing at Wyoming is hard on visiting teams, especially those that have come in ranked in the Top 25 this season.

Josh Allen threw for two touchdowns, including a 29-yard score to C.J. Johnson with 1:07 left in the game, and Wyoming stopped a 2-point conversion attempt by San Diego State with no time on the clock to upset the No. 24 Aztecs 34-33 on Saturday.

It was Wyoming's second win this season over a Top 25 team. Wyoming beat then-No. 13 Boise State three weeks ago in Laramie. The Cowboys last beat two ranked teams in one season in 1999.

More from FoxSports

Allen, who completed 16 of 31 passes for 282 yards and also rushed for 56 yards, said the two wins over ranked teams felt similar.

"Playing here in front of this crowd and at this elevation, it's hard to play for four quarters when you're an away team," he said, referring to the oxygen-thin 7,220 foot elevation of War Memorial Stadium.

Brian Hill added 131 yards on 31 carries and two TDs for the Cowboys (8-3, 6-1 Mountain West).

Johnson finished with five catches for 85 yards.

San Diego State (9-2, 6-1) was led by Christian Chapman, who completed 15 of 26 passes for 211 yards and two TDs. Chapman's last TD pass was a 23-yard desperation heave that Quest Truxton caught on the rebound with no time left. The play capped an 11-play, 99-yard drive, and also involved a lengthy review that overturned the original call on the field of an incomplete pass.

"Seeing that he caught that, it was like a little stab in the stomach," Wyoming's Johnson said. "But then seeing them go for two, I had faith in our defense."

Aztecs coach Rocky Long elected to go for the win and Chapman's 2-point conversion pass attempt was knocked away by defensive back Antonio Hull.

In going for the win, Long said he felt his team had the momentum after the 99-yard drive, which he described as "unbelievable."

"Wish we would have moved the ball like that the other 99 percent of the game," he said.

Rashaad Penny and Juwan Washington both returned kickoffs for touchdowns for the Aztecs. Penny's was 93 yards, and Washington's 92 yards.

Donnel Pumphrey, who entered the game as the nation's leading rusher, was held to 76 yards on 17 carries.

"We just didn't give him much room to run," Wyoming coach Craig Bohl said.

Still, Pumphrey surpassed Hall of Famer Tony Dorsett for third place on the NCAA career rushing list and now has 6,127 yards. He trails Ron Dayne, who amassed 6,397 yards at Wisconsin, and Ricky Williams, who gained 6,279 yards at Texas.

THE TAKEWAY

San Diego State: The Aztecs have not won a game in the last 39 years when ranked. Since 1977, San Diego State is 0-4 in games played when the Aztecs are in the Top 25.

Wyoming: The upstart Cowboys, who were 2-10 last year, remain tied for the conference's Mountain Division title with a shot at getting to the conference championship game on Dec. 3. If the Cowboys win their last game, they likely will face San Diego State for the conference championship back in Laramie.

"I'm happy we're still in the hunt for the Mountain West championship, and we got one more game to go," Hill said.

POLL IMPLICATIONS

San Diego State: The Aztecs likely will tumble back out of the poll. They had won six straight to get back into the poll after being ranked earlier this season after San Diego State won its first three games.

HARD TIME IN WYOMING

In its four previous games, San Diego State had outscored its opponents 183-32. The offense entered Saturday's game averaging 293.9 rushing yards a game. The Aztecs' defense was limiting opponents this season to an average of 15.2 points and 282.5 yards a game.

On Saturday, Wyoming racked up 487 yards and outrushed San Diego State 205-178.

STREAKS BROKEN

Wyoming's win broke San Diego State's 17-game win streak against Mountain West opponents. It also snapped the Aztec's six-game winning streak and ended their 22-game streak of limiting opponents to less than 400 yards of total offense.

UP NEXT

San Diego State: The Aztecs return home for their final regular-season game, hosting Colorado State next Saturday.

Wyoming: The Cowboys close out the regular season on the road at New Mexico next Saturday night.