Colorado entered with the NHL's worst power play, but scored the tying and winning goals with the extra man after going 0-for-3 to start the game.
Ryan Smyth set up Stastny at the side of the net when Miikka Kiprusoff went down and Stastny slid the winning goal into an empty net.
The goal came after Jarome Iginla was penalized in overtime for tripping John-Michael Liles as he skated through center ice, a call that was emphatically disputed by coach Mike Keenan and booed by the sellout crowd of 19,289.
Colorado had tied it at 2-2 at 13:33 of the third period when Milan Hejduk wristed a shot inside the far post from the faceoff dot after taking a drop pass from Stastny.
Robyn Regehr scored short-handed at 12:58 of the second period to give the Flames a 2-1 lead.
Smyth scored the other goal for Colorado, which won for just the second time in their eight games and moved into the ninth spot in the Western Conference - just two points back of a playoff spot.
Dustin Boyd also scored for Calgary, which opened a two-point lead in the Northwest Division over second-place Minnesota.
Colorado was one of the busiest teams in the 24 hours leading up to Tuesday's trade deadline, signing free agent Peter Forsberg on Monday and then acquiring defensemen Adam Foote and Ruslan Salei on Tuesday.
Foote was in the lineup, though he didn't appear on the bench until six minutes left in the first period, as his flight from Columbus arrived late.
Regehr's first career short-handed goal came on a slap shot from the blue-line that first changed directions off Foote's stick in the slot then caromed off the skate of unsuspecting Avalanche defenseman Scott Hannan at the side of the net and trickled past goaltender Jose Theodore.
Theodore made 26 saves for the Avalanche, while Kiprusoff had 31.
Calgary tied it at 1-1 at 15:35 of the first period on Boyd's sixth goal of the season coming one second after a Flames power play had expired. Owen Nolan set up the goal with a superb pass from the side boards, threading a pass through the goal crease to an uncovered Boyd who one-timed a shot past Theodore.
Colorado opened the scoring when Smyth broke down his off wing and flicked a backhand shot toward the net from 30 feet that seemed to fool Kiprusoff deflecting off his glove and into the top corner.
Notes: Colorado had just five healthy defenseman without Foote. ... Calgary LW Alex Tanguay (neck) didn't play. ... After scoring 20 goals in his first 43 games, Calgary LW Kristian Huselius has just one in his last 21.