According to ESPN, the three-year deal is worth $11.75 million, including $4 million guaranteed.
Hours earlier, Whitner tweeted that he was joining the Bengals, which a published report later confirmed. But Whitner later changed course, tweeting: "Its official...49ers it is! Funny how God works...instead of playing against the 9ers I'm playing w/ the 9ers..."
The signing of Whitner, 26, could signal that the 49ers intend to part ways with Taylor Mays, a second-year pro, and Dashon Goldson, a starter the last two seasons. The 49ers agreed to a one-year contract with safety Madieu Williams earlier in the week. Williams, 29, was released by the Minnesota Vikings last week.
Goldson acknowledged the inevitable with his own tweet: "Sorry guys thanx for all ur support but not gonna be back. See ya"
Whitner, the No. 8 overall pick in 2006 NFL Draft, spent five seasons with the Buffalo Bills. He registered 140 total tackles last season with seven passes defensed and an interception.