Updated

Ryan O'Reilly and the Colorado Avalanche were unable to reach a deal for more than a month.

A few hours after he signed an offer sheet with Calgary, the restricted free agent was back with the Avalanche.

The Flames announced Thursday that they signed O'Reilly to a multiyear offer sheet. Colorado had a week to match it, but did so by the end of the day. The team announced the decision during the first period of Thursday night's game against Calgary.

"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."

Sherman said the speed with which Colorado matched the offer showed its commitment to O'Reilly.

"Given the timeframe we moved on this, it's clear what our object was," Sherman said. "We moved very quickly and efficiently to make a decision to match the offer."

The Avalanche players found out before their 5-4 win over the Flames that O'Reilly was back with the team.

"That was great news," captain Gabriel Landeskog said. "I know there was 24 guys who were happy in here to have him back."

Calgary GM Jay Feaster said the Flames put forth the offer sheet after failing to trade for the forward.

"We think Ryan O'Reilly is a franchise player," Feaster said. "We had extensive trade discussions with Colorado but felt the price to acquire the player via trade was too steep. We felt it would negatively impact our future, so we made the decision to go ahead with the offer sheet."

TSN in Canada reported the deal is worth $10 million over two years, which includes 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.

Feaster said the contract was written to make it harder for Colorado to match.

"We tried to structure it in a way that we felt would give us a better chance to get him," he said.

O'Reilly will travel to Denver for a physical and if everything checks out, he will join the Avalanche on their three-game road trip starting Sunday in Columbus.

Had Colorado not matched the offer it would have received Calgary's first- and third-round picks in the NHL draft. By retaining O'Reilly, the Avalanche cannot trade the forward for a year from Thursday.

Sherman said Calgary's decision to try to sign one of Colorado's restricted free agents was strictly business.

"It's their right within the CBA to put that offer sheet forward and we have our rights within the CBA to match it," Sherman said. "If that's the way they want to do their business, that's their right. The fact that we received the offer the day of the game, against them, that's their prerogative. That's their business."

Avalanche center Paul Stastny was pleased Colorado wasted no time in matching the offer.

"It shows that we aren't going to let one of our top players go for draft choices," he said. "Management wasn't hesitant to match it. They didn't wait seven days. Doing it right away shows that they are committed."

The 22-year-old O'Reilly has not played this season while trying to work out a contract with Colorado. He was the team's leading scorer last season with 55 points.

O'Reilly was the 33rd pick in the 2009 draft. In three NHL seasons, he has 39 goals and 69 assists in 236 career games.