Williams, who played college football at Maryland, chose the Redskins after visiting both Washington and the Atlanta Falcons on Friday and Monday, respectively.
Terms of the deal were not immediately known.
Drafted in the second round of the 2004 draft by Cincinnati, Williams played in 15 games for the San Francisco 49ers last season but recorded only nine tackles and no interceptions.
The Redskins are looking for competition for free safeties DeJon Gomes and Reed Doughty after releasing Oshiomogho Atogwe earlier this offseason. Last month, the team signed former Viking Cedric Griffin, who has played cornerback during his six-year career but could be used at free safety.
For his career, the 6-foot-1, 203-pound Williams has made 488 tackles and 12 interceptions, while recording 35 pass breakups and four fumble recoveries.