DENVER (AP) -- The Colorado Avalanche got the best of Calgary on and off the ice.
Gabriel Landeskog had a goal and two assists, and the Avalanche scored three times in the third period to rally past the Flames 5-4 on Thursday night.
Matt Duchene, Paul Stastny and David Jones each had a goal and an assist for Colorado, which improved to 6-2-1 at home.
The game had added intrigue when it was announced before the opening faceoff that the Flames had signed restricted free agent Ryan O'Reilly to an offer sheet. While Calgary was taking a 2-0 lead early in the first period, the Avalanche announced they had matched the offer and were keeping the 22-year-old forward.
''That was great news,'' Landeskog said. ''I know there were 24 guys who were happy to have him back.''
TSN in Canada reported the deal was for $10 million over two years, including a $2 million signing bonus. TSN said O'Reilly's salary would be $1.5 million for the first season and $6.5 million the second year.
Calgary general manager Jay Feaster said the decision to put forth an offer sheet came after he tried to trade for O'Reilly.
''We had extensive trade discussions with Colorado but felt the price to acquire the player via trade was too steep,'' he said. ''We felt it would negatively impact our future, so we made the decision to go ahead with the offer sheet. We tried to structure it in a way that we felt would give us a better chance to get him.''
The Avalanche didn't hesitate in matching the offer.
''This was a goal of ours from the outset, to get Ryan signed,'' Avalanche general manager Greg Sherman said. ''That goal has never changed. Sometimes the process takes a little longer than you would expect or want, but he's staying with the Colorado Avalanche.''
Jarome Iginla scored twice and Jay Bouwmeester and Mike Cammalleri each had a goal for the Flames, who had earned at least one point in eight consecutive games at Colorado.
The excitement off the ice was nearly matched on it. Bouwmeester and Cammalleri scored 33 seconds apart to put the Flames ahead 2-0 just 5 minutes into the game.
Iginla made it 3-0 late in the first and it appeared the Flames were going to win for the eighth time in their last nine games at Pepsi Center before it all fell apart.
''We played a great first period and found a way to throw it to the dumpster,'' coach Bob Hartley said. ''We didn't deserve it. They deserved it. They outworked us in the second, they outworked us in the third. At 3-0 we had the game fully in control, so we only have us to blame.''
Ryan O'Byrne and Jones started the comeback with goals early in the second to cut it to 3-2.
Iginla's second late in the period made it a two-goal game again, but Landeskog made it 4-3 just 23 seconds into the third.
It was Landeskog's first goal since Jan. 22. He missed 11 games with a head injury.
''Landeskog had his best game of the year,'' Avalanche coach Joe Sacco said. ''It was almost like he said we weren't going to lose this game.''
Six minutes later, Stastny knocked in Landeskog's rebound to tie it. Duchene scored the winner when he tipped in a centering pass from Jamie McGinn 10:52 into the third.
''We knew we needed just that one goal,'' Landeskog said. ''We got it and we kept going to get that next one. When we took over momentum the crowd fed off of that.''
The comeback left the Flames a little stunned.
''That's as hard as any loss this year,'' Iginla said. ''There's no way that should happen.''
Joey MacDonald stopped 31 shots for the Flames. Semyon Varlamov made 19 saves for Colorado.
NOTES: The Flames acquired forward Brian McGrattan from Nashville for defenseman Joe Piskula. McGrattan did not appear in a game this season for the Predators and recently finished a two-week conditioning assignment in the AHL. ... O'Byrne's goal was his first since Oct. 20, 2011, a span of 85 games. ... Jiri Hudler had three assists for Calgary.