Sanchez (9-8) allowed one run on only two hits, struck out seven and issued two walks for the Giants, who avoided the sweep and climbed back within one game of the Phillies in the NL wild card chase.
Buster Posey delivered two RBI in the victory. The Giants halted a three-game skid overall.
Cole Hamels (7-10) suffered the loss after he was charged with five runs on seven hits with five strikeouts for the Phillies, who saw their four-game win streak halted and lost for only the second time in their last eight overall.
Philadelphia remained 2 1/2 games behind Atlanta in the NL East, after the Braves lost to Washington earlier Thursday.
The Giants opened the scoring with three runs in the first inning. Freddy Sanchez lined a one-out single and scored when Posey followed with a double to the gap in left-center. Pat Burrell then walked and Jose Guillen’s base hit brought home Posey for a 2-0 lead. The rally was capped by Juan Uribe’s RBI single which scored Burrell, who’d advanced to third on Guillen’s single.
In the top of the third, the Giants pushed their lead to four. Again it was Sanchez and Posey igniting the charge, as Sanchez led off with a single and then raced around to score on Posey’s double to center that was nearly caught by Shane Victorino.
Pablo Sandoval led off the fourth inning with his ninth home run of the season.
Philadelphia’s only offense of the night, except for Victorino’s single in the third, came in the ninth. Sanchez surrendered a leadoff single to Victorino and was immediately lifted in favor of reliever Sergio Romo. Placido Polanco flied out before Chase Utley singled to put runners on first and second.
After Romo struck out Jayson Werth, pinch-hitter Mike Sweeney delivered a two- run double down the line in left field. That brought closer Brian Wilson into the game, and he induced a fly out by Raul Ibanez to earn his 34th save.
Phillies slugger Ryan Howard is scheduled to begin a rehabilitation assignment on Friday for Single-A Lakewood. Howard has been on the DL since August 2 with a sprained left ankle…Hamels lost his third straight start and has not earned a victory since July 11 at Cincinnati…Phillies reliever David Herndon pitched three perfect relief innings…Philadelphia begins a three-game series at home against Washington on Friday, while the Giants travel to St. Louis for a weekend set…This was the 100th consecutive sellout at Citizens Bank Park.