DENVER (AP) -- Jim McElwain became the first Colorado State coach to win his debut in 42 years Saturday when the Rams rallied past their arch rival for a 22-17 win over the Colorado Buffaloes.
Garret Grayson completed 14 of 21 passes for 173 yards and two touchdowns and Jared Roberts kicked two fourth-quarter field goals after the Rams had fallen behind 17-16.
Grayson outdueled Kansas transfer Jordan Webb, who was 22 of 41 for 187 yards and two TDs for the Buffaloes.
McElwain, the former offensive coordinator at defending national champion Alabama, became the first Rams coach to win his debut since Jerry Wampfler in 1970. None of other 12 Rams coaches who have faced Colorado had ever beaten the Buffs on their first try.
Will Oliver's 30-yard field goal put the Buffaloes ahead 17-16 early in the fourth quarter, but Roberts hit from 48 yards out with 6:39 left to put the Rams back on top, 19-17.
After the Buffs went three-and-out, the Rams had to salt this one away with backups because tailback Chris Nwoke was on the sideline with a leg injury.
Freshman Donnell Alexander took off on a 37-yard run, and Terrel Smith's face mask penalty tacked on another 15 yards. But the Buffs stood their ground, forcing the Rams to settle for another field goal, this one from 32 yards out with 2:56 remaining.
Strong safety Trent Matthews' game-sealing interception was nullified by Lanston Tanyi's roughing penalty, and the Buffaloes had a first down at the Rams 47 with 1:27 left.
They turned the ball over on downs 40 seconds later.
The Rams thought they had a 100-yard fumble return for a touchdown by defensive back Austin Gray, but after the celebratory cannon fired, the officials ruled Malcolm Creer was down before the ball popped out.
The Buffaloes declined to try for the go-ahead field goal but then failed to score on fourth-and-goal when defensive end Shaquil Barrett pressured Webb into an overthrow of tight end Nick Kasa.
Colorado had taken possession on the Rams 15 when Will Pericak recovered a fumble.
Webb found freshman Nelson Spruce eight times for 64 yards, including a sliding 12-yard grab on fourth-and-7 from the 28 before hitting him for a 15-yard touchdown that put the Buffs ahead 7-3.
Webb's second TD toss, a 9-yarder to Tyler McCulloch, came after Matthews was whistled for pass interference on a fourth-and-5 pass from the Rams 30.
Matthews' recovery of a muffed punt by D.D. Goodson at the Colorado 20 got the Rams back into the game. On the next play, Grayson found Dominique Vinson uncovered for the score with 26 seconds left in the half. Pericak, however, blocked Roberts' extra point.
Freshman Joe Hansley's 32-yard TD catch put Colorado State ahead 16-14 in the third quarter.