Terms of the contract were not announced by the team. NFL Network's Adam Schefter reported Wednesday Hill signed a three-year contract.
Hill, a six-year NFL veteran who hadn't thrown a pass until December, led the 49ers to victories over Cincinnati and Tampa Bay after taking over for Smith and Trent Dilfer, who were both out with injuries. In 2 1/2 games, Hill was 54-for-79 with 501 yards and five touchdown passes and one interception.
He was held out of the season finale, a 20-7 loss to the Browns, due to a back injury.
Hill, who would have been an unrestricted free agent next month, spent his first four seasons with Minnesota, mostly as a third quarterback who took only two snaps. He joined the 49ers in 2006, again as the No. 3 quarterback.
After the 49ers finished 5-11, coach Mike Nolan said Hill had earned the right to compete with Smith, the No. 1 overall draft pick in 2005 who has struggled along with his teammates in his three NFL seasons.
Smith and Nolan had a prolonged public disagreement last season over the 49ers' handling of Smith's shoulder injury, which eventually forced him out for the season after a poor comeback attempt.
Hill's style also might fit better into the system favored by new offensive coordinator Mike Martz. Dilfer, who struggled in most of his appearances during Smith's absence, isn't expected to return to San Francisco next season despite his stated desire to keep playing.
The Associated Press contributed to this report.