Updated

Alex Smith and the San Francisco 49ers were working Tuesday night to finalize a three-year contract, a person with knowledge of the negotiations said.

The person, speaking on condition of anonymity because no announcement had been made, said Tuesday night final details were still being worked out and it could be complete as soon as Wednesday.

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

NFL Network first reported the sides had agreed on a new deal. Earlier in the day, Peyton Manning was formally introduced in Denver after the 49ers pursued the four-time NFL MVP. Coach Jim Harbaugh worked out Manning at Duke last Tuesday.

The 27-year-old Smith had met with Miami on Sunday but ultimately decided to stay put with the storied franchise that drafted him first overall in 2005.

Smith had a breakthrough season last year, helping San Francisco reach the NFC title game.

"Welcome Back (hashtag)AlexSmith. Let's get the train rolling now," tweeted 49ers defensive lineman Ricky Jean Francois.

Both sides made it clear after the Niners' 20-17 overtime loss to the eventual Super Bowl champion New York Giants in the NFC championship game they planned to work out a new deal.

It just took a little while longer than expected after Manning briefly entered the picture.

While Smith told the South Florida Sun-Sentinel on Sunday he was surprised Manning became a free agent, he said he understood the business side of the NFL — so perhaps it won't take long for Harbaugh and Smith to get over San Francisco's weeklong courting of Manning.

"It's a very strong relationship," Harbaugh told reporters while leaving team headquarters Tuesday, noting nothing had changed in Smith being "our guy." He declined to discuss negotiations.

Last spring, Harbaugh handed over his playbook to Smith during a brief lifting of the lockout — a show of confidence in the QB even though he wasn't under contract. Smith wound up re-signing for $4.9 million, then earned a $1 million bonus for making the playoffs as the 49ers ended an eight-year stretch without a postseason berth or winning record.

"I don't think there will be any bad blood because he went to Miami for an interview," former 49ers running back great Roger Craig said Tuesday. "That's part of the process, it's the nature of the beast. He has to do what's best for him and his family. I'm pretty sure the 49ers are going to work something out. Players love him, fans love him. I love him.

"I think Alex wants to get this put to bed so he can focus on having a great year, an All-Pro year this year," Craig said. "He doesn't want this dark cloud over him. It's really his time, and he understands the business. He knows it's a good situation."

49ers CEO Jed York had said the team's three-year offer still stood despite the pursuit of Manning, and it was just up to Smith to sign.

Long booed by his home 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 to win its first division title since 2002. That was a remarkable turnaround under first-year coach and 15-year NFL quarterback Harbaugh — the NFL coach of the year — who declared his confidence in Smith as a winner from Day 1 when hired away from Stanford in January 2011.

San Francisco went 6-2 on the road and won four of those games in comeback fashion — and Smith rallied his team from behind five times in all, not to mention a 36-32 victory against the favored Saints in the NFC divisional playoffs. Smith completed a 14-yard touchdown pass to Davis with 9 seconds left to seal it after Drew Brees had put his team ahead.

"I can see these guys dominating for the next decade," Craig said. "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."