The Buffaloes (1-2) overcame a slow start and a rash of penalties to beat the Rams (2-1) for the fourth straight time in Denver.
The Rams were playing without two of their top defenders. Standout senior linebacker Mychal Sisson broke his right ankle last week and watched on crutches from the sideline with pass-rusher Broderick Sargent, who tore an ACL in CSU's opener.
The bevy of backups helped stifle the Buffs until they got their ground game going behind Rodney Stewart, who rushed 19 times for 98 yards to go with seven catches for 93 yards and two punt returns for 9 more.
Colorado receiver Paul Richardson had four catches for 27 yards and three big drops one week after setting a school record with 284 yards on 11 receptions in an overtime loss to Cal.
Hansen also threw for a school-record 474 yards in that game. This time, he was held to 215 yards passing but scored twice on keepers and threw two touchdown passes.
His second touchdown run, from 2 yards out, capped a 16-play, 85-yard drive that ate up more than 10 minutes after the Rams had pulled within 21-14 with some trickery.
Rams wide receiver Charles Lovett took a quick pass from quarterback Pete Thomas in the left flat and threw a perfect 23-yard touchdown pass to tight end Crockett Gillmore early in the fourth quarter.
After Thomas' first career rushing touchdown, a 4-yard scamper on the game's opening drive, the Buffs scored touchdowns on Hansen's 2-yard keeper that marked Colorado's first rushing touchdown in 15 quarters, and Hansen's 24-yard strike to Kyle Cefalo with 12 seconds left in the first half.
In the third quarter, Hansen hit Toney Clemons for a 44-yard score when free safety Austin Gray was beaten badly.
Cefalo's score followed a couple of big breaks for the Buffaloes. Colorado State's Joe McKay got a hand on Darragh O'Neill's punt, the ball bounced for 11 yards and CSU's Derek Good tried to pounce on it, only to watch it squib away from him and into the hands of Colorado's Ryan Deehan.
With the second chance, Hansen drove the Buffs down the field, capping the drive with the scoring toss to Cefalo.
The Buffs managed just 10 yards of offense in the first quarter, when they were whistled for 40 yards in penalties, but they bounced back. The Rams had just 67 yards rushing all afternoon, and Thomas threw for 157 yards but didn't get the ball into the end zone after his keeper on the first drive. He was sacked three times.