Rivers completed 24-of-33 passes for 240 yards for the Chargers (6-7), who have won two in a row.
Ryan Mathews carried the ball 20 times for 114 yards for San Diego, which improved to 17-2 in December under head coach Norv Turner. Mathews, who has rushed for over 100 yards in three straight games, also caught six passes for 34 yards.
Gates caught seven passes for 68 yards and Patrick Crayton hauled in three passes for 37 yards and a score.
Ryan Fitzpatrick connected on 13-of-34 passes for 176 yards and two interceptions for the Bills (5-8), who have lost six straight and have been eliminated from playoff contention.
Steve Johnson caught four passes for 116 yards in defeat.