Lee (11-7) was commanding in his first regular season start against the Giants in two years, striking out eight, including Cody Ross four times, and not walking a hitter. He set down 10 in a row at one point in his major league-leading fifth shutout this season.
It was also some revenge for Lee, who lost twice to the Giants in last year's World Series pitching for the Texas Rangers.
Pence had three hits and drove in two runs and is hitting .360 (9 for 25) since joining the Phillies.
Madison Bumgarner, a postseason hero for the Giants, recovered after allowing two long balls in a game for just the second time this year and the first since June 15.
Bumgarner (6-11) retired 13 of 14 following Mayberry's blast. He went eight innings, allowing six hits, walking two and striking out nine.
The Phillies, who have won seven straight since losing two in a row to the Giants in Philadelphia, remain undefeated since acquiring Pence, who homered in a Phillies uniform for the first time. Pence ended a 19-game, 67-at bat homerless drought when he connected on Bumgarner's first pitch in the second inning.
The Phillies never had more than one runner on in an inning the rest of the way.
Lee, who threw the 10th shutout of his career, made it all academic, needing just 74 pitches to get through the first seven innings and 106 overall. He sent the Giants to their sixth loss in seven games, slicing a half-game off their NL West lead over the Arizona Diamondbacks, who open a three-game series against the Los Angeles Dodgers on Friday.
Pence added an RBI single in the ninth against Santiago Casilla.
NOTES: Giants IF Mark DeRosa was activated from the 60-day DL. IF Brandon Belt was optioned to Triple-A Fresno and LHP Alex Hinshaw was designated for assignment. ... The Phillies send rookie RHP Vance Worley to the mound Friday against the Giants. He threw a three-hitter against the Giants in Philadelphia, his first career complete game. Worley has won five consecutive decisions. ... LHP Jonathan Sanchez gets his first start since coming off the disabled list. He last pitched June 24. Sanchez is 3-1 with a 2.86 ERA in five starts against the Phillies. ... Phillies RHP Ryan Madsen went on paternity leave. RHP Scott Mathieson was recalled to take his place. ... Phillies IF Chase Utley was out of the starting lineup for the first time since June 26. ... Lee is 4-0 in four career starts against the Giants. ... Giants OF Carlos Beltran is 1 for 6 lifetime against Worley. Phillies OF Shane Victorino is hitting .400 (6 for 15) against Sanchez. Jimmy Rollins is .063 (1 for 16) against Sanchez.