Hunter Pence's game-winning bases-loaded single in the bottom of the ninth inning lifted the San Francisco Giants to a 7-6 win over the San Diego Padres in the season finale for both teams.
The Padres held a 6-5 lead entering the ninth, but Francisco Peguero led off the bottom half with a game-tying homer into the seats in left-center off Huston Street (2-5).
Tony Abreu then singled before Brandon Belt walked. Buster Posey was then intentionally walked after Abreu scampered to third on a passed ball to load the bases.
Pence, who finalized a five-year deal worth $90 million earlier Sunday, stepped up next and belted a single to deep center to plate Abreu.
"That's a tough one, whether it's April, May, June, July, August or September," Padres manager Bud Black said. "Huston has been so reliable for us the past couple of years and it just goes to show that players are not invincible."
Pence finished with two hits and three RBI for the defending World Series- champion Giants (76-86), who won four of their last five games to close the year.
"You couldn't ask for a better story today with everything that happened," Giants manager Bruce Bochy said. "It felt like a playoff game. I guess the guys really wanted a piece of third place."
Sergio Romo (5-8) tossed a scoreless top of the ninth to pick up the win
Jedd Gyorko smacked a grand slam for San Diego (76-86), which had won three of its last four tilts coming in.
The game was tied 2-2 after four innings before Gyorko cracked his blast over the wall in left in the fifth to give San Diego a 6-2 spread.
San Francisco got a run back in the home fifth on Belt's RBI double and Pence brought home two more in the seventh with a single to pull the hosts within 6-5.
Giants starter Guillermo Moscoso allowed five runs on four hits and four walks over 4 1/3 innings, while Padres starter Tyson Ross fanned seven and surrendered three runs on seven hits and a walk over six frames.