Jose Tabata's three-run double capped the big rally.
After St. Louis beat Atlanta earlier in the day, Pittsburgh needed a win to keep the division lead.
Garrett Jones and Jordy Mercer hit solo homers for the Pirates.
Jeanmar Lopez (3-0) got the win. Guillermo Moscoso (1-2) took the loss.
Marco Scutaro and Brandon Crawford each had two RBI for the Giants, losers of four of their last five games.
Aaron Carter is still in love with Hilary Duff
Millions of Getty images now available for free via embed tool