SAN FRANCISCO Angel Pagan lined a game-ending double to right field with one out in the ninth inning, and the Giants returned from a rough trip to beat the San Diego Padres 3-2 on Friday night.
Santiago Casilla (2-1) struck out two in a 1-2-3 ninth for the win. Shortstop Brandon Crawford made a great pickup on Jesus Guzman's grounder for the second out.
Luke Gregerson (1-2) gave up Gregor Blanco's leadoff bloop single to shallow left to start the rally, then pinch hitter Andres Torres reached on a fielder's choice and stole second before coming home on Pagan's hit.
It was his first game-winning hit since last July 1 against the Reds.
Madison Bumgarner struck out a season-high 10, and Hunter Pence hit an RBI double for the Giants. Bumgarner struck out 10 or more batters for the ninth time in his career.
Chase Headley hit a tying, two-out homer in the sixth just over leaping left fielder Blanco.
The tying run kept Bumgarner from becoming the first Giants pitcher to win his first four starts since Tim Lincecum in 2010.
After San Diego hit three home runs Wednesday against Dodgers ace Clayton Kershaw, Headley's first clout of 2013 gave the Padres home runs in eight of their last nine games. But San Diego had its three-game winning streak snapped.