Hunter Pence had four hits for the Giants, who have won three of four.
Brandon Crawford singled off Brandon League (0-1) with one out in the 12th and advanced to second on a groundout by Brandon Hicks. His bouncer deflected off third baseman Juan Uribe to shortstop Hanley Ramirez, who threw to first for the out.
But the Dodgers were unable to get the lead runner on the play, and it cost them.
Crawford went to third on a wild pitch and Sanchez hit a sharp one-hopper that glanced off the glove of diving second baseman Justin Turner and into center field.