The deal announced Wednesday will pay Elliott $1.7 million next season and $1.9 million in 2013-14 for a $1.8 million annual cap hit.
Elliott hadn't been expecting the Blues to approach him.
"I was happy that they wanted me to stay. Whenever you get that, you know that they're impressed with you and your work ethic," Elliott said.
Elliott, in the midst of a career season, was slated to become an unrestricted free agent on July 1.
He was not promised a job in training camp, signing a two-way contract that pays him $600,000 in the NHL this season and $105,000 in the minors should he be demoted. However, Elliott beat out Ben Bishop in camp to earn the backup job to goalie Jaroslav Halak.
"He's the perfect example of perseverance," coach Ken Hitchcock said. "He just had to become more compact in his game, and he's done that, he's done it beautifully.
"He's resurrected a career based on being able to look in the mirror and not feel sorry for himself, and make adjustments."
The 26-year-old Elliott is 15-5-1 and is second in the NHL with a 1.68 goals-against average. He also has a .937 save percentage and tied a career high with five shutouts.
"The situation he was in last summer, wondering where he was going to play and finding a good home here and doing his job on the ice, I think it's a great story," general manager Doug Armstrong said. "Now he can settle in and take his career to the next level."
Elliott and Halak have combined for a 1.98 goals-against average, tied for the best in the NHL, and the duo leads the league with eight shutouts. Elliott is 9-1-1 at home.
"Obviously, with our record, I think it's been really good," Elliott said. "Whenever you get a couple of guys pushing each other, I think it helps a lot."
The goalie likes the makeup of this team that has surged under Hitchcock and is among the NHL's best.
"I think we have a pretty good thing going right now," Elliott said Wednesday night. "I've been on the other side of it, and I'm not a guy that will want to roll the dice all the time.
"I just like to have it done and not worry about it, so I can just play hockey."
Pierre LeBrun covers the NHL for ESPN.com. Information from The Associated Press contributed to this report.