Rainey's long score came on the game's second play from scrimmage and the Bucs (4-9) never trailed after that.
Mike Glennon was held to 90 passing yards on 9-of-25 efficiency with two interceptions but also hurled a pair of TD passes as Tampa Bay notched a fourth win in five games.
Vincent Jackson and Timothy Wright each made a scoring reception.
Buffalo (4-9) was undone by four interceptions tossed by rookie EJ Manuel. He made good on 18-of-33 passes for 184 yards.
Dan Carpenter booted a pair of field goals for the Bills.