Juan Uribe's ninth-inning sacrifice fly scored Aubrey Huff to give the Giants a 3-1 lead in the National League Championship Series. Huff reached on a one-out single and moved to third on Buster Posey's single, his fourth hit of the game.
"We had the right guy at the plate there," manager Bruce Bochy said. "He's come through so many times for us and got a ball he could handle to get deep enough in the outfield."
The rally came off Game 2 winner Roy Oswalt, who threw 111 pitches on Sunday. Closer Brad Lidge had also been warming up in the top of the ninth.
"We faced him a couple of nights ago and he's got great stuff," Posey said of Oswalt. "Just battling, that's all you can do. Fortunately I got a pitch and got it on the barrel and was able to get a hit."
Sandoval's moment was one of redemption. He had endured a season-long slump and hadn't started since Game 2 of their NL Division Series. Bochy inserted him into the lineup because Uribe was sidelined with a sore wrist.
Four pitches after hitting one just foul down the right-field line, Sandoval hit one to a vacant section of the outfield, driving in Pat Burrell and Cody Ross.
The game started well for the Giants.
Freddy Sanchez reached on a single and advanced to third on a couple of wild pitches from Phillies starter Joe Blanton, who last pitched Oct. 3. Sanchez was driven in by Posey, who got his first postseason RBI.
Posey drove in another in the third when he doubled in Huff from first to double the Giants' lead to 2-0.
The Giants' 21-year-old starter, Madison Bumgarner, who played at nearby Class A San Jose with Posey at the start of last season, cruised through the first few innings.
Then, the Phillies had one of those innings they had in their runs to the World Series over the last two years, scoring four in the fifth.
By the end of that half inning, Bumgarner was out of the game and the Phillies were on top 4-2.
The Giants took back a run in the bottom of the fifth, when a two-out single by Huff knocked in Andres Torres.