Cody Ross began the rally with a single up the middle off Brad Brach (0-2) and moved to second on a wild pitch. After Andres Torres popped out, Padres manager Bud Black chose to intentionally walk Carlos Beltran to put runners on first and second. Ross then moved to third on a fielder's choice by Pablo Sandoval, which brought DeRosa to the plate.
He ripped a line drive to second, which hit just off the top of the glove of Orlando Hudson and rolled into short right field, allowing Ross to trot home with the winning run.
Ramon Ramirez (3-3) tossed a scoreless top of the 12th to earn the win.
Sandoval finished 3-for-6 with an RBI and a run scored, Beltran had three hits and Ross added a pair for the Giants, who have won three straight but remain 8 1/2 games behind the NL West-leading Diamondbacks and 6 1/2 behind the wild- card leading Braves.
Trailing 2-0, the Padres plated a pair of runs in the seventh. Pinch-hitter Kyle Blanks reached on a fielder's choice and Aaron Cunningham ripped a double into the left-field gap to give San Diego runners on second and third with two outs. Giants manager Bruce Bochy summoned Guillermo Mota from the bullpen to face Bartlett, who came through with a game-tying double.
San Diego got the go-ahead run into scoring position in the ninth against Sergio Romo when Hudson ripped a single to center and moved to second on a well-placed sacrifice bunt by James Darnell, but Romo fanned Blanks and pinch- hitter Jeremy Hermida to keep the game tied.
In the 11th, Chris Denorfia slapped a one-out single and stole second to get into scoring position with two outs. Darnell walked to put two men on for Blanks. The Padres were unable to capitalize however, as Blanks struck out to end the inning.
"Our bullpen did a really good job tonight," Bochy said. "We needed them."
San Francisco drew blood in their first at-bat. Ross beat out an infield single to start the frame and advanced to third on a double by Beltran. Ross then crossed the plate on a single to left by Sandoval to give the Giants the early lead.
San Diego put the tying run at third in the second inning when Hundley smacked a one-out single, stole second and moved to third on a groundout by Denorfia. Hundley was left there however, as Giants starter Matt Cain struck out Hudson to end the inning.
The Giants widened their lead with a run in the fourth to make it 2-0. Sandoval led off the frame with a single to left and Brett Pill slapped one back up the middle to put two men on with no outs. Following a strikeout from Orlando Cabrera, Justin Christian blooped a ball into center field to plate Sandoval. San Francisco had a chance to tack on further with runners on second and third and one down, but Eli Whiteside fouled out and Cain struck out to end the inning.
The Giants are 3-2 on their current six-game homestand...San Diego leads the majors in stolen bases with 160...Cain worked 6 1/3 innings, allowing one run on four hits while fanning six and walking three...Padres starter Corey Luebke gave up two runs on 10 hits over six innings while striking out eight without walking a batter...Romo extended his scoreless streak to 18 2/3 innings.