Cody Ross delivered yet another big hit as the Giants tried to extend their 2-1 edge in the best-of-seven matchup.
In a series dominated by pitching, the bats finally woke up against fourth starters Madison Bumgarner for San Francisco and Joe Blanton for Philadelphia. Neither started made it out of the fifth, both being removed with the lead before qualifying for a win, as the two managers looked for a key victory.
Placido Polanco hit a two-run double as the Phillies emphatically ended a 14-inning scoreless streak with four runs in the fifth to take a 4-2 lead.
But the Giants responded with an RBI single by Aubrey Huff in the bottom half and Sandoval's big hit in the sixth to regain the lead by scoring the first runs all postseason against the Phillies' bullpen.
Pat Burrell started the rally with a leadoff walk off Chad Durbin and went to third on Ross' double down the left-field line. Sandoval followed with a line shot down the right-field line that first-base umpire Jeff Nelson called foul as right-field ump Ted Barrett tried to get out of the way. Replays were inconclusive.
Sandoval made any controversy moot a few pitches later when he drove a ball into the gap in left-center - far from any foul lines - to score the two runs that gave the Giants a 5-4 lead.
The Phillies quiet bats finally woke up in a big fifth inning. Ben Francisco, starting in place of the slumping Raul Ibanez, got it started with a leadoff single for his first hit in 13 career postseason at-bats.
Carlos Ruiz followed with another single, the first back-to-back hits in the series for Philadelphia. The runners moved up on a sacrifice bunt by Blanton and Shane Victorino followed with a single to center for Philadelphia's third hit in 22 at-bats with runners in scoring position in the series.
Aaron Rowand made a strong throw home and Buster Posey caught it on the short-hop before tagging out the slow-footed Ruiz for the second out. The run was Philadelphia's first since Jimmy Rollins' three-run triple in the seventh inning of Game 2 and the first earned run off a San Francisco starter at home in 26 2-3 innings this postseason.
The nifty play by Rowand and Posey didn't preserve the lead for long as Polanco followed with his double off reliever Santiago Casilla that made it 3-2. After an intentional walk and a hit batter, Casilla threw a wild pitch that scored Polanco with the fourth run. Casilla struck out Rollins to end the inning.
The Giants responded with a run in the bottom half on Huff's RBI single that knocked out Blanton. Jose Contreras came in and struck out Posey to preserve the lead, extending the Phillies relievers scoreless streak to 9 1-3 frames this postseason.
Blanton, who had throw only one inning of relief since his last start on Sept. 29, got off to a shaky start for the Phillies. He threw a pair of wild pitches in the first inning - matching his regular season total - after Freddy Sanchez singled with one out. Posey made him pay with a two-out single up the middle for his first RBI of the postseason to give the Giants the early lead.
The Giants got to Blanton again in the third when Huff singed with two outs and scored on Posey's double.
While Blanton is often the forgotten man in Philadelphia's star-studded rotation, he has been something of a good luck charm in past postseasons. He has started Game 4 of a postseason series for the Phillies five times previously, with Philadelphia winning four of those games.
Dusty Baker, who left the team on bad terms after managing the Giants to the World Series in 2002, was back in San Francisco sitting next to managing general partner Bill Neukom.
Three of Baker's former players - Matt Williams, Will Clark and Robby Thompson - threw out the ceremonial first pitches.