The bases were loaded with one out in the eighth and the last thing San Francisco manager Bruce Bochy wanted was an inning-ending double play.
So he turned to speedster Fred Lewis as a pinch hitter for Kevin Frandsen, and Bochy wound up looking like a genius.
Lewis hit a sharp grounder to second but beat out the double-play attempt, driving in the decisive run Monday night in a 5-4 victory over the Arizona Diamondbacks that improved the Giants' fragile playoff hopes.
"I thought it was going to be a close play," Lewis said, "but with one out, I was just trying to get down the line as fast as possible."
The win moved San Francisco within four games of idle Colorado in the NL wild-card chase with 12 to play.
"We're going to fight to stay in this," Bochy said. "We had to fight tonight and it was a big win for us."
The Giants scored their runs on one RBI single, two groundouts, an error and a sacrifice fly.
"That's us," Bochy said. "We scratch and claw for lots of runs, and we executed a perfect bunt that helped us."
Five relievers shut down Arizona after starter Barry Zito gave up four runs, three earned, in 4 1-3 innings. Sergio Romo (5-2) got the win and Jeremy Affeldt threw a scoreless eighth for his major league-leading 32nd hold.
Brian Wilson allowed a two-out single in the ninth, then struck out Justin Upton looking on a 3-2 pitch for his 35th save in 41 chances.
"Pitching kept us in the game," Lewis said.
Mark Reynolds drove in two runs with his 43rd homer and Upton's single scored the other two for Arizona.
Pablo Sandoval doubled and singled for the Giants, who took advantage of three Diamondbacks errors.
Esmerling Vasquez (3-3) walked Travis Ishikawa leading off the eighth, then Aaron Rowand laid down a beauty of a bunt. Vasquez and second baseman Ryan Roberts collided trying to field it, leading the Arizona pitcher to throw wild past first base.
The Diamondbacks' third error of the game put runners on second and third with no outs. Roberts hurt his left leg on the play and had to leave the game.
After Nate Schierholtz popped out to shortstop, Eugenio Velez was walked intentionally to load the bases.
Frandsen was playing because second baseman Freddy Sanchez twisted his left knee in the first inning, so Bochy decided Lewis was his best option.
The two-strike grounder was hit sharply to second baseman Augie Ojeda, who threw to shortstop Stephen Drew for the force at second. Drew bobbled the ball ever so slightly, and that was enough for Lewis to beat the relay throw.
"One critical, small little glitch," Arizona manager A.J. Hinch said. "It probably had to be a perfect play to turn it on a guy like him. As soon as there was one little hesitation, he was safe."
Cardinals 7, Astros 3
At Houston, Mark DeRosa homered twice and St. Louis sent the Astros to their eighth straight loss, hours after the team fired manager Cecil Cooper.
Third-base coach Dave Clark was named Houston's interim manager for the final two weeks of the regular season, but he lost his major league managing debut.
DeRosa also had a two-run double for the Cardinals, who reduced their magic number for winning the NL Central to three. Kyle Lohse (6-8) beat Wandy Rodriguez (13-11) for his first win since Aug. 10.
Braves 11, Mets 3
At New York, Chipper Jones homered and drove in four runs.
Garret Anderson and Matt Diaz also connected for the Braves, who have won nine of 11 to stay in the playoff race. They moved within five games of Colorado for the wild card with 12 remaining.
Atlanta opened a six-game trip with its most runs since it set a season high in a 15-2 win at New York on Aug. 19. Martin Prado had three hits, Nate McLouth scored three times and Derek Lowe (15-9) pitched five innings to help the Braves improve to 11-5 against the Mets this season.
Daniel Murphy homered for New York, which has lost seven of nine.
Cubs 10, Brewers 2
At Milwaukee, Derrek Lee and Aramis Ramirez hit back-to-back homers, and Tom Gorzelanny tied a career high with nine strikeouts.
Lee drove in four runs and Ramirez two more for the Cubs, who won for the second time since general manager Jim Hendry suspended volatile outfielder Milton Bradley for the season on Sunday.
Mike Cameron hit two solo homers off Gorzelanny (6-2).
Chicago's first four batters of the game reached and scored against Braden Looper (13-7).
Padres 11, Pirates 6, 11 innings
At Pittsburgh, Chase Headley's career-high fifth hit drove in the go-ahead run for San Diego in its third straight win over the Pirates.
Headley hit his third double of the night off Jeff Karstens (3-5) in the 11th to send the Padres to their eighth win in 12 games. Headley hit his 12th homer, and Adrian Gonzalez and Nick Hundley also went deep for San Diego, which led 6-2 in the eighth. Heath Bell blew a save in the ninth.
Rookie slugger Garrett Jones hit his 20th homer for last-place Pittsburgh, which has lost 20 of 23.