Terms of the contract were not disclosed but media reports said the six-year deal would be worth up to $100 million to Williams, 27, who will become the highest-paid defensive player in the NFL.
Williams, who was flown to Buffalo this week on a private jet with the team's general manger and defensive coordinator, said he was excited about joining the organisation and said a determined fan base that showed support by putting his name on pizzas and on signs along roads helped get the message across.
"You don't get many chances like this and opportunities to come in and be the guy who can help the team get across the hump and that's definitely what I am here for," Williams said.
"My whole intention is to come here ... and make this thing happen. It' a great opportunity for myself and the team and for us to succeed and get better. This city is looking for that."
Williams, regarded as one of the top free agents available, was drafted first overall in 2006 by the Houston Texans and would be counted on to bolster a Bills defence that managed just 29 sacks last season.
His signing gave Buffalo their most accomplished pass rusher since Pro Football Hall of Famer Bruce Smith, who left the team in 2000 as the franchise and NFL all-time sacks leader.
The Bills, who finished 6-10 in the 2011 campaign and missed the playoffs for the 12th straight year, entered the offseason intent on bolstering their pass rush.
Williams, who was limited to five games last season due to a torn chest muscle, has 53 sacks and 241 tackles in 82 career games during six NFL seasons with the Texans.
"It's an exciting day for us and for our football team, we got a lot better," said Bills General Manager Buddy Nix.
"Once we got him here and got him to listen, not to people who have heard about Buffalo but the people who live here, then you find out what unique place it is and he's going to help it get even better."