Hector Sanchez singled in Pablo Sandoval in the bottom of the 12th inning, giving the San Francisco Giants a 3-2 win over the Houston Astros on Saturday night.

Sanchez, whose throwing error in the top of the ninth helped Houston score the tying run and force extra innings, hit a sharp grounder off Houston closer Brett Myers that bounced off the glove of Astros second baseman Jose Altuve and went into right field. Sandoval, who opened the inning with an infield single, easily beat the throw home from Matt Downs.

Jeremy Affeldt (1-1) got the last out in the top of the 12th.

Sanchez finished with a career-high four hits while Melky Cabrera had two to add to his majors-leading total for the Giants, who moved into first place in the NL West, a half-game ahead of the Los Angeles Dodgers.