Brandon Belt and Angel Pagan supplied the dramatics as the Giants topped the Rockies 3-2 in 10 innings at AT&T Park on Monday.
Belt tied the game by driving in Pagan in the eighth inning and he scored the leadoff man again in the 10th, giving the Giants their 11th walk-off win.
"We want to finish as strong as we can no matter what situation we're in," Belt said. "I believe there is momentum we can gain and carry into next year."
Despite the win, the Los Angeles Dodgers officially eliminated the Giants from the National League West Division race on Monday by beating the Arizona Diamondbacks 8-1.
Pagan reached base with one out in the 10th by squeezing a single in between first and second and he crossed the plate after Marco Scutaro singled and Belt dropped a base hit into left field on a 1-2 count.
"Once I got two strikes, I was just trying to put the ball in play," Belt said.
Belt tied it up at 2-2 in the eighth by smacking a two-out double into the right-field corner on the first pitch of his at-bat, scoring Pagan.
"I put just enough wood on it to get it down the line," Belt said.
Pagan reached second base after Nolan Arenado bare-handed a chopper to third and threw it past first baseman Ryan Wheeler into the Rockies' bullpen.
Pagan went 3-for-5 on the night. He's batting .324 (11-for-34) since his return from hamstring surgery on Aug. 30.
Starter Tim Lincecum (9-13) allowed the Rockies to score the game's first run in the second inning by falling asleep as Buster Posey fielded a routine dribbler in front of the plate. Rather than covering home, Lincecum stood and watched as Posey picked up the ball and threw it to first, enabling Arenado to sneak around to score from second base.
The Rockies added a second run in the third when Troy Tulowitzki lined a single to center, bringing in D.J. LeMahieu. Lincecum shut the door after that.
He allowed two earned runs on seven hits over eight innings of work in what may have been his second-to-last home start in a Giants uniform.
"I didn't feel very good the first couple innings rhythm-wise, kind of just timing off," Lincecum said. "But after that I just wanted to attack the zone and try to throw good quality strikes."
Santiago Casilla (6-2) picked up the win by recording the last outs in the 10th after Javier Lopez retired the first two Rockies batters. Sergio Romo pitched a scoreless ninth inning.
Posey tied the game at 1-1 in the bottom of the second, driving his 15th home run over the left-field fence. The 2012 NL MVP is swinging a hot bat right now, batting .439 (18-for-41) over his last 11 games.