Sanchez hit a two-run double, creating a 3-3 tie with one out in the bottom of the fifth inning followed by a run-scoring error by Ryan Howard.
Velez hit a two-run single in the sixth, while Aaron Rowand also had an RBI for the Giants, who won three times in the four-game series.
Winner Barry Zito (7-10) gave up three runs and six hits in six innings with no walks and five strikeouts.
Philadelphia's Jimmy Rollins cracked a solo homer in the fourth, a run scored on an error by Sanchez in the second and Carlos Ruiz had one RBI for the Phillies, who have lost four of five.
The losing pitcher was starter Cole Hamels (7-6).