Izzy Matthews gave the Rams (7-5, 5-3 Mountain West) the lead at 27-24 with a 39-yard run and Hansley capped the scoring with 10:03 left in the fourth. Matthews helped Colorado State run out the clock in the final five minutes and had a career-high 140 yards rushing.
Fresno State (3-9, 2-6) took the lead back at 31-27 on Marteze Waller's 2-yard run. Waller finished with 112 yards rushing and a touchdown.
Colorado State returned three kicks for touchdowns, the first on Hansley's a 75-yard punt return to open the scoring less than three minutes in.
The Bulldogs rattled off 24 straight to lead by 17 before Hansley took another punt 61 yards with less than a minute to go in the half.
Kevin Nutt, Jr. then returned the opening kickoff of the second half 96 yards and Colorado State failed to convert the extra point to make it 24-20.