Terms of the deal were not available Tuesday night, but the team had previously offered Smith a three-year, $24 million contract.
Rosenthall: Smith does right thing
"Oh, I'm excited," tight end Vernon Davis said in a text message. "I'm glad. Alex deserves all good things that come his way."
San Francisco coach Jim Harbaugh told reporters on Tuesday that he and Smith had "a very strong relationship," and that nothing had changed in Smith being "our guy."
Long booed by fans at Candlestick Park, Smith threw for 3,150 yards and 17 touchdowns with only five interceptions last year as San Francisco went 13-3 and advanced to the NFC Championship Game.
"I can see these guys dominating for the next decade," former 49ers running back Roger Craig said Tuesday. "The kind of intangibles Harbaugh brings to the table, he's very competitive and a smart guy and players believe in him, and just look how Alex stepped up his game."
The Associated Press contributed to this report.