PITTSBURGH, July 6 (UPI) -- Melky Cabrera hit a two-run homer during a five-run fourth inning that brought San Francisco from behind Friday and the Giants then fought off Pittsburgh 6-5.
The Pirates had a four-game winning streak halted and lost at home for just the 14th time this season. That is the fewest home setbacks in the majors.
The Giants, however, went in front for good with their big fourth inning. Ryan Theriot doubled home a run in the fourth before scoring in front of Cabrera's eighth homer of the year.
Theriot also had a sacrifice fly in the eighth to give San Francisco a 6-4 lead, allowing the Giants room to withstand a solo homer from Padro Alvarez in the eighth.
The five-run fourth made a winner out of Barry Zito (7-6) who gave up four runs on seven hits in five innings. Four San Francisco relievers combined to allow a run on two hits in the final four frames with Sergio Romo pitching a perfect ninth for his fifth save.
Erik Bedard (4-10) suffered the loss, surrendering four runs on four hits in 3 2/3.
San Francisco snapped a three-game skid.