SAN FRANCISCO -- Francisco Peguero hit his first major league home run, a game-tying shot to lead off the bottom of the ninth inning, and Hunter Pence drilled a game-winning RBI single four batters later as the San Francisco Giants overcame a Jedd Gyorko grand slam to beat the San Diego Padres 7-6 in the season finale Sunday afternoon.
The come-from-behind win allowed the Giants (76-86) to tie the Padres (76-86) for third place in the final National League West standings. San Francisco, which won the World Series last year, earned 18 fewer regular-season wins than in 2012, the second-biggest drop-off among all major league teams.
Gyorko capped arguably the greatest season in baseball history by a rookie second baseman with a fifth-inning grand slam, propelling the Padres into a 6-2 lead.
However, San Diego never scored again against five Giants relievers, including Barry Zito, who made an eighth-inning cameo in what is expected to be his final game for San Francisco.
Peguero entered the game under unfortunate circumstances in the top of the ninth. He replaced left fielder Gregor Blanco, who suffered a knee injury when he collided with center fielder Angel Pagan while chasing Will Venable's pinch-hit triple.
Padres closer Huston Street (2-5) got ahead of the rookie 1-2, but Peguero then blasted his homer into the first row of the bleachers in left-center field. The home run came on Peguero's 45th big-league at-bat.
Street faced four other Giants and didn't get any of them out. Tony Abreu followed Peguero's homer with a single, and Brandon Belt drew a walk.
After a passed ball, the Padres chose to walk Buster Posey intentionally, setting the stage for Pence, who before the game held a press conference to formally announce a new five-year, $90 million contract.
Pence laced a full-count pitch to straightaway center field for the game-winner.
Sergio Romo (5-7) pitched around Venable's triple to record a scoreless ninth inning.
Gyorko's grand slam, his second homer of the three-game series, came on the third pitch thrown by Giants reliever Jake Dunning. Alexi Amarista, Chris Denorfia and Jesus Guzman also scored on the blast, which turned 2-2 tie into four-run Padres advantage.
The home run was Gyorko's 23rd of the season, the third-most all-time among second basemen. Only the Florida Marlins' Dan Uggla (27 in 2006) and the New York Yankees' Joe Gordon (25 in 1938) have hit more as a rookie second baseman.
Gyorko finished the season with 63 RBIs, tops on the Padres. No other rookie second baseman ever led his team in RBIs.
The 25-year-old also played a flawless game in the field to finish the year with a .992 fielding percentage, the best ever for a rookie second baseman. He made only four errors all season, the fewest among second basemen who played at least 108 games.
Gyorko came to the plate in the fifth inning after Giants starter Guillermo Moscoso walked Guzman to load the bases. Moscoso, named earlier this week to replace Matt Cain as Sunday's starter, was charged with five runs on four hits and four walks in 4 1/3 innings. He struck out four.
The Giants rallied after Padres starter Tyson Ross left following six effective innings with a 6-3 lead. Ross gave up two run-scoring doubles to Belt among three runs allowed on seven hits. He struck out seven and walked just one.
The Giants got within 6-5 on a two-out, two-run single by Pence off Nick Vincent in the eighth. Vincent bounced back to get Pablo Sandoval to ground to first baseman Tommy Medica with the potential tying run on second base.
Denorfia had three hits, including a double. Nick Hundley had a solo homer, his 13th of the season, among just seven San Diego hits.
Zito entered with two outs in the eighth to face former Oakland A's teammate Mark Kotsay, who was batting for the final time in his 17-year career.
Zito struck out Kotsay and left the mound to the standing ovation he was denied because of circumstances when he made his final start as a Giant on Wednesday night. The Giants will pay Zito a $7 million buyout this winter to end his seven-year, $126 million contract. The deal included an $18 million for an eighth year that the team will not exercise.
Pence, Abreu, Belt and Sandoval all had two hits for the Giants.
NOTES: Padres 3B Chase Headley announced before the game that he is scheduled to undergo surgery Tuesday to repair a torn meniscus in his left knee. ... The Giants won the season series from the Padres 11-8. San Francisco prevailed in the season series against all of its NL West rivals for the third consecutive year. ... The Giants sold out every home game for a third straight season. Their season attendance total exceeded 3.3 million. ... Both teams will open the 2014 season on March 31. The Padres will host the 2013 NL West champions, the Los Angeles Dodgers, while the Giants will visit the second-place Arizona Diamondbacks.