The Bills were 34-46 under Gailey, including a second-consecutive 6-10 result in 2012. The season ended Sunday with a 28-9 win over the New York Jets, which snapped a three-game losing streak.
Buffalo allowed 435 points -- the second highest total in team history -- which was 26th in the NFL this year.
The entire coaching staff was relieved of duties along with Gailey.
"I understand this is a business. We didn't get the job done," Gailey said in a team statement.
"I've been called by two other teams to turn things around, was able to do it. I wasn't able to get this one done soon enough and I understand that completely.
"This will probably be, and I say probably, but I think it will be the first place that's ever fired me that I'll pull for."
Gailey previously coached the Dallas Cowboys for two seasons, going 18-14 and making the playoffs both seasons. He coached collegiately at Georgia Tech for six seasons between the stints with the Cowboys and Bills.