Gailey succeeds Perry Fewell, who took over as interim coach in November after Dick Jauron was fired. The Bills finished the year 6-10, their fifth losing season in a row. They haven't made the playoffs since 1999.
"We get the best qualified guy. He was on the list early," Bills General Manager Buddy Nix said. "I got full confidence in him."
Gailey coached the Dallas Cowboys to playoff appearances in 1998 and '99 and most recently was offensive coordinator for Kansas City, which fired him before the start of the season.
He also was head coach at Georgia Tech from 2002 through 2007, compiling a 44-33 record and guiding the Yellow Jackets bowl games in all six seasons. His NFL career also includes stints as an assistant with Miami, Denver and Pittsburgh.
"There are two types of coaches; those who hope to win and those who expect to win. I don't just hope to win, I expect to win," Gailey said. "We've got to do it on the field. I can't make any promises other than that."
Scarlett Johansson steps out with fiance after pregnancy reveal
Interpol investigating stolen passports on missing flight