James McDonald tossed seven innings of one- run ball to guide the Pittsburgh Pirates to a 3-1 win over the San Francisco Giants in second installment of a three-game set at PNC Park.

McDonald (9-3) struck out 10 and allowed just four hits without walking a batter to win his fourth straight start.

"Getting ahead of guys and being aggressive was my game plan," McDonald said. "Don't be afraid of (anybody) and go right after them. I had good fastball command today and got ahead of a lot of guys. I put them away when I had to."

Neil Walker doubled twice and drove in a run while Michael McKenery and Pedro Alvarez had an RBI apiece for the Pirates, winners in five of their last six.

Jason Grilli struck out the side in the eighth and Joel Hanrahan worked around a lead off bunt-single in the ninth to secure his 23rd save of the season.

Ryan Theriot had a pair of hits and drove in the lone run for San Francisco, which has dropped four of its last five. Gregor Blanco had two hits and scored a run.

Ryan Vogelsong (7-4) was pegged with the loss after giving up three runs on eight hits while fanning five over seven innings.

"Obviously (McDonald) is having a good season," Vogelsong said. "Throwing the ball well so going in you know it is going to be a tough game. He pitched a little bit better than me today."

The Pirates got on the board in the third to take a 1-0 lead. McDonald worked a leadoff walk, then scored when Walker doubled to left-center.

Play was later delayed for 27 minutes with two outs due to rain. Vogelsong was able to get Garret Jones to fly out to end the inning following the delay.

McKenery's solo homer in the fourth pushed the margin to 2-0.

The Giants made it 2-1 in the sixth. Blanco singled, moved to second on a wild pitch and then scored when Theriot singled up the middle.

The Pittsburgh came back with a run of its own in the home half to extend its lead to 3-1. Andrew McCutchen singled and then scored when Alvarez doubled down the left-field line.

Blanco reached on a bunt-single in the ninth, then moved to third on a throwing error by McKenry, but Hanrahan was able to retire the next three hitters to secure the win.

"We want to win every game we can," McKenery said. "At the end of the day if we're in first that's awesome, but we just want to try to win that game that day."

Game Notes

Walker extended his hitting streak to 11 games...The Pirates are 12-2 on Saturdays this season...Pittsburgh has at least one extra-base hit in a season-high 38 consecutive games...The Pirates recalled first baseman Matt Hague from Triple-A Indianapolis and optioned catcher Eric Fryer to Indianapolis before the game...Vogelsong has tossed at least six innings in all 16 of his outings this season...San Francisco is 20-23 on the road this season.