Bumgarner (1-6) had started eight games this year and was winless until Thursday, compiling an earned run average of 4.25 in 42 1/3 innings.
In a reversal of form, he allowed the Dodgers four hits and walked two with three strikeouts through eight scoreless innings.
He came out to start the ninth and retired the first two batters, but in quick succession he allowed a single to Rod Barajas and a run-scoring double to Jerry Sands.
After Bumgarner walked pinch-hitter Jay Gibbons, closer Brian Wilson came on in relief. Wilson issued a walk to pinch-hitter James Loney to load the bases, putting the tying runs in scoring position.
Wilson finally got Jamey Carroll on a liner to right for the final out. It was Wilson's 13th save.
Freddy Sanchez drove in two of the San Francisco runs with a sacrifice fly in the third and a single in the sixth.
Chad Billingsley (2-4) suffered the loss, allowing three runs on six hits in six innings.