Pablo Sandoval hit a two-run home run in the game sweep at the hands of 4 win.

In the 11th with Mark Melancon (6-4) on the mound, Cody Ross worked a one-out walk before Jeff Keppinger flied out. Sandoval then stepped to the plate and crushed a pitch over the wall in center for a 6-4 advantage.

Ramon Ramirez then set the Astros down in order in the bottom of the frame for his third save of the season.

Brandon Belt hit a three-run home run while Mike Fontenot also drove in a run for the Giants, who snapped a three-game slide. Jeremy Affeldt (2-2) got the win for pitching two scoreless innings.

The win, coupled with Arizona's loss to Atlanta on Sunday, moved the Giants to just 1 1/2 games back of the Diamondbacks for first place in the NL West.

J.D. Martinez went 3-for-5 with two RBI for the Astros, who were looking for their first five-game winning streak of the season.

Neither starter factored into the decision as Henry Sosa was touched for four runs on four hits over five innings for Houston while Dan Runzler, making his first big league start in place of an injured Jonathan Sanchez, gave up four runs on three hits in just 1 2/3 innings of play.