Updated

Matt Diaz finished 2-for-4 with two RBI 2, in the rubber match of a three- game series.

Ryan Ludwick added three hits, an RBI and two runs scored, while Andrew McCutchen hit a two-run homer, walked three times and crossed the plate on four occasions for the Pirates, who took two of three in the set to erase the sting of a 10-game losing streak prior their arrival in the Bay Area.

Jeff Karstens (9-6) worked six innings, allowing eight hits and two runs while fanning nine for the win.

Pablo Sandoval hit a solo homer and Orlando Cabrera drove in the other run for the Giants, who skidded to their fifth loss in seven.

Jonathan Sanchez (4-7) lasted just 4 1/3 frames, charged with four hits and five runs -- four earned -- with four walks despite six strikeouts.