Dilfer started six games for the 49ers last season, passing for 1,166 yards with seven touchdowns, 12 interceptions and a 55.1 passer rating before incurring a season-ending concussion.
"Trent Dilfer is a true professional in every meaning of the word," 49ers coach Mike Nolan said. "He is one of the most respected players in the league for good reason. Trent has provided great value to our team over the past two years in terms of his leadership, knowledge of the game and play on the field."
Dilfer missed the 49ers' final three games last season with the latest in a series of concussions, and the 49ers were unlikely to bring him back this year after third-stringer Shaun Hill performed well in two starts last December.
San Francisco also recently signed veteran quarterback J.T. O'Sullivan, a favorite of new offensive coordinator Mike Martz, who has said Alex Smith and Hill will compete for the starting job.
Dilfer, the sixth overall pick in 1994 by Tampa Bay, led the Baltimore Ravens to a Super Bowl victory after the 2000 season, but was dropped by the club shortly afterward.
The Fresno State product has played for the Buccaneers (1994-99), Baltimore (2000), Seattle (2001-04), Cleveland (2005) and San Francisco. He started 113 games in his career, making the Pro Bowl in 1997.
He didn't play at all in his first season with the 49ers in 2006, instead serving as a mentor to Smith. After last season, Dilfer said he hoped to continue playing, but he also prepared for life after football with a temporary job as a studio analyst for the NFL Network.
Dilfer would have received a $500,000 roster bonus if he still was with the 49ers on March 15.