Matt Robinson's two-yard touchdown pass to halfback Arthur Whittington with 39 seconds to play won the game in Irving, Tex.
Whittington, obtained from the Raiders this summer, outraced linebacker David Morze to the flag after catching a short swing pass on fourth and one.
Tony Dorsett's nine-yard touchdown run and Rafael Septien's 48-yard field goal, all in the first half, gave Dallas a 10-0 lead.
The Bills missed on three field goal tries in the listless affair played on a 90-degree evening before 48,612 in Texas Stadium. But safety Bill Simpson intercepted a Gary Hogeboom pass to setup the winning touchdown.
The Bills also capitalized on Dorsett's fumble for a touchdown in the third quarter. End Sherman White recovered the ball at the Dallas 46, and the Bills scored seven plays later on Booker Moore's two-yard run.
Buffalo missed two excellent scoring chances in the first quarter.
The Bills drove from their eight-yard line to the Dallas 37 but Gary Anderson missed a 5-yard field goal attempt.
Simpson intercepted a White pass and returned it 35 yards, but Dallas held and Jim Asmus missed a 42-yard field goal attempt.
The Cowboys drove 75 yards for their first touchdown.