SAN DIEGO -- With two home runs already in hand, Pablo Sandoval came up swinging for the fences in his final at-bat Wednesday.
"I was looking for my pitch," Sandoval said.
Sandoval jumped on a 2-1 fastball from San Diego reliever Dale Thayer and drove it into the seats in left for his third home run of the game, leading the San Francisco Giants to a 13-5 romp over the Padres at Petco Park.
Sandoval, who went 4-for-5 with six RBIs, hit three home runs for the second time in his career. He also accomplished the feat in Game 1 of the 2012 World Series in a win over the Detroit Tigers.
Teammate Brandon Crawford, who also homered, provided extra incentive for Sandoval, who had hit only one long ball since the All-Star break and three in the past 80 games.
"He got me fired up a little bit," said Sandoval, who has 13 homers this season. "When he hit his home run, he asked me, 'How many home runs do I got?' I said 10. He said, 'I got nine.' I said, 'OK, we'll see what's going on right now.'"
Hunter Pence and Hector Sanchez also went deep as the Giants (62-77) avoided a three-game sweep and left San Diego tied with the Padres (62-77) for fourth place in the National League West.
Sandoval hit a two-run homer in the fifth inning off Padres reliever Brad Brach, then a solo shot in the eighth off Brad Boxberger and a three-run blast in the ninth off Thayer.
"He's one of those guys when he's hot, he's hot," Padres manager Bud Black said. "It's really tough to get him out. It looks like to me the last couple of (at-bats), he's swinging the bat well. He's getting his hits. He's tough to pitch to because he can hit any pitch."
Added Giants manager Bruce Bochy, "I think we're all asking where's that been. He came out swinging. That's a huge day."
Tim Lincecum worked his first game at Petco since throwing a no-hitter against the Padres on July 13. Although Lincecum struggled for much of his outing, including a shaky first inning, he received plenty of offensive support and emerged with the win. Lincecum (9-13) allowed five runs on seven hits with five strikeouts and four walks in 5 2/3 innings.
San Diego's Eric Stults had one of his roughest starts of the season. Stults (8-13) was tagged for seven runs on nine hits with four strikeouts and no walks in 4 2/3 innings.
The Giants trailed 2-1 before getting two-run homers from Pence and Sanchez in the fourth inning. Pence drove a 2-2 pitch from Stults an estimated 408 feet into the upper deck, while Sanchez jumped on the first pitch he saw from the left-hander and drilled it into the Padres' bullpen in left-center.
Pence chased Stults with an RBI double in the fifth that increased the lead to 6-2. Sandoval followed with his homer off Brach.
San Francisco piled it on the San Diego bullpen in the late innings, with Sandoval's final homer capping the scoring.
"Guys just woke up with the bats," Bochy said.
The Padres got off to a good start.
Will Venable, who led off the first with a single, stole second and an advanced to third on a groundout, then scored on a passed ball by Sanchez.
Leading off the second, Ronny Cedeno homered for only the second time this season. He drove a 3-2 pitch from Lincecum an estimated 426 feet into the upper deck in left to put San Diego on top 2-0.
Crawford opened the third with a solo shot off the foul pole to slice the lead in half.
NOTES: C Buster Posey, who wasn't in the starting lineup Wednesday, has a swollen ring finger on his right hand after a wild pitch from LHP Madison Bumgarner struck him during Tuesday's loss to the Padres. Posey's status is day-to-day. ... Padres 3B Chase Headley returned to the lineup after missing six games with a lower back injury, and he homered off Lincecum in the fifth. ... The Giants entered the game with the fewest homers in the majors, 80. ... Arizona Diamondbacks RHP Trevor Cahill (5-10, 4.39 ERA) will face San Francisco RHP Ryan Vogelsong (3-4, 5.49) in the opener of a four-game series that begins Thursday at AT&T Park. ... The Padres will be off Thursday before hosting the Rockies for a three-game set starting Friday. Colorado RHP Juan Nicasio (8-7, 4.82) will face RHP Burch Smith (0-1, 11.37) in the opener. ... The game drew a crowd of 15,762, the second-lowest attendance figure for the Padres this season.