In his previous appearance, Bumgarner (8-12) allowed Houston six runs on 11 hits in 6 2/3 innings while taking the loss. This time he limited the Astros to a run on five hits in 6 1/3.
His solid start kept the Giants within three games of first-place Arizona in the National League West.
Ramon Ramirez worked 1 2/3 innings in relief of Bumgarner to keep San Francisco in front and Santiago Casilla, filling in as closer while Brian Wilson spends time on the disabled list, struck out two in the ninth for his second save.
Jeff Keppinger doubled in the two San Francisco runs in the fifth. Matt Downs scored from third for Houston in the seventh on a groundout by Clint Barmes.
The hard-luck loss went to J.A. Happ (4-15), who surrendered only one earned run on four hits in six innings.