The New Orleans Saints released Sanders earlier this month as they scrambled to get under the salary cap. He had been scheduled to make $8 million, with $2 million guaranteed, in 2021.
Sanders took to social media to express his excitement over joining the reigning AFC East champs, writing: "Bills mafia... let's goooooooo!"
Sanders, 33, caught 61 passes for 726 yards and five touchdowns in 14 regular-season games last season. He caught another eight passes for 51 yards in the playoffs.
He has been selected to two Pro Bowls and has appeared in three Super Bowls -- winning a title with the 2015 Broncos.
Later Tuesday, the Bills traded tight end Lee Smith to the Atlanta Falcons for a 2022 late-round pick, a league source told Schefter. Smith, 33, made his four catches last season count, scoring two touchdowns and totaling 35 yards.
Smith was a fifth-round draft pick of the New England Patriots in 2011 out of Marshall.
ESPN's Mike Triplett contributed to this report.