A few hours after he signed an offer sheet with Calgary, the restricted free agent was back with the Avalanche.
The Flames announced earlier Thursday they had 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 objective was," Sherman said. "We moved very quickly and efficiently to make a decision to match the offer."
The offer is for two years, $10 million, according to a source.
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.
"Very excited to join back up with the boys," O'Reilly tweeted. "Can't wait to get on the ice and play in front of the great avalanche fans again. Sorry to everyone about the situation. I'm very glad to say that it is over and i now can focus on what I love to do."
"That was great news," Avalanche captain Gabriel Landeskog said after the team's 5-4 come-from-behind win over the Flames. "I know there were 24 guys who were happy to have him back."
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.
The offer sheet is structured as $1 million in salary for this season, plus a $2.5 million signing bonus, and then $6.5 million salary in the second year, the source said.
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."
The Flames, who called O'Reilly a "franchise player," explained their decision to tender an offer sheet in a statement released Thursday night.
"While we attempted to acquire him via trade, we felt the asking price was too steep and would negatively impact our future. As such, we decided to tender an offer sheet and were very pleased to have the player accept our offer," the team said. "We attempted to structure the offer so as to enhance our chances of getting the player. We attempted to improve our hockey team and will continue to do so going forward."
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.
Information from ESPN.com's Pierre LeBrun and The Associated Press was used in this report.