Khabibulin, who turned aside 29 shots, struggled to a 10-32 record last season. His win Friday lifted him to 10-6 this season.
Jay McClement produced Colorado's only goal 3:29 into the second, but Jordan Eberle tallied on the power play midway through the period and Gagner produced a backbreaking goal with just 3 seconds left in the stanza.
Gagner's goals were his second and third of the season. He had 15 in each of his previous two campaigns.
Semyon Varlamov allowed four goals on 35 shots. Both teams came into the game having lost two in a row.
'Happy' fan videos make Pharrell cry [VIDEO]
Pregnant Mila Kunis wins 'Best Villain' at MTV Movie Awards