San Francisco (4-8) scored with 6:51 remaining in the quarter, added a 50-yard field goal by Joe Nedney in the second quarter and limited the Bills to a 22-yard third-quarter field goal by Rian Lindell.
Hill completed 14-of-23 passes for 161 yards and Bruce ended up with five catches for 67 yards. The 49ers' Frank Gore contributed 66 yards running and 23 receiving.
Buffalo starter Trent Edwards was 10-for-21 passing for 112 yards before leaving the game with a groin injury. J.P. Losman took over in the second half and hit 11-of-17 passes for 93 yards.
Marshawn Lynch ran for 134 yards for the Bills (6-6).
Justin Bieber crashes Drake Bell's album release party
Chipotle plans first price increase in 3 years