Elite Loyalty Sports tweeted that the contract is worth $138 million and includes $55.1 million in guarantees. The contract makes Williams the highest-paid offensive lineman in NFL history.
Williams, 32, was set to hit free agency at 4 p.m. EDT Wednesday.
The eight-time Pro Bowl selection joined the 49ers in an April 25 trade from the Washington Football Team. He started 14 games last season for San Francisco. Williams spent the first nine years of his career with Washington.
The star lineman also hinted that the 49ers could be close to signing free agent center Alex Mack. Williams posted a photo of himself with Mack -- with both players in 49ers uniforms -- Wednesday on Instagram.