Spencer Johnson and Jairus Byrd each took back intercepted Tim Tebow passes for touchdowns in the fourth quarter and Leodis McKelvin returned a punt 80 yards for a score for the Bills (6-9).
Ryan Fitzpatrick passed for 196 yards on 15-of-27 attempts in the victory, which snapped Buffalo's seven-game losing streak and put a crimp in the Broncos' post-season hopes.
Denver (8-7), fighting for the AFC West title, lost its second straight and fell into a tie with Oakland atop the division.
The Raiders beat Kansas City in overtime Saturday while the San Diego Chargers had a chance to forge a three-way logjam for the division lead with a win over Detroit later in the day.
Gal Gadot cast as Wonder Woman for 'Batman vs. Superman'
Exploding whale video goes viral on Internet