Romo completed his first 13 passes of the game and finished 23-for-26 with 270 yards and three touchdowns for the Cowboys (5-4), who have won two straight after being humiliated by Philadelphia in Week 8.
Gailey went 18-14 over a two-year stint with Dallas from 1998-99, but was fired by owner Jerry Jones after short playoff exits in both of those seasons.
Gailey then had a couple of coordinator positions along with a six-year stint at Georgia Tech before taking over the realms in Buffalo last season.
One of the suprise teams of the season, the Bills (5-4) won their first three games and came into the contest tied with New England and the New York Jets for the top spot in the AFC East, but have dropped their past two games.
Ryan Fitzpatrick's touchdown pass to David Nelson in the second quarter was the only offensive highlight of the day for Buffalo as Fitzpatrick finished the game 20-for-31 with just 146 yards and three interceptions. Fred Jackson carried the ball 13 times for 114 yards.