George Kontos (2-0) gave up one hit and struck out three in two innings in relief to earn the win. Santiago Casilla pitched the ninth for his sixth save in nine tries.
Duvall and Kontos both arrived from Triple-A Fresno after midnight to replace Matt Cain and Brandon Belt on the roster.
''Any time you get up here, it doesn't matter how late,'' Duvall said.
Kontos hopes his third trip to the big leagues this season is his last.
''Every time I come up I expect to be here for the rest of my career,'' he said.
Giants starter Ryan Vogelsong gave up four runs - three earned - and 11 hits in three-plus innings. But San Francisco's bullpen combined for six scoreless innings.
Making his first start since May 18 because of an elbow injury, Lee (4-5) had a rare rough outing against San Francisco. Lee was 5-0 with a 0.88 ERA in six career games against the Giants. He allowed five earned runs in 51 innings in those six starts before giving up six runs and 12 hits in 5 2-3 innings in this one with several scouts watching in the stands.
If Lee shows he's healthy and pitches effectively, he is a prime candidate for a trade before the July 31 non-waiver deadline. The four-time All-Star and 2008 AL Cy Young Award winner already was traded once by the Phillies in December 2009 on the same day they acquired Roy Halladay in a separate deal.
The Phillies are headed toward their second straight losing season and will be looking to acquire young players from contending teams for some of their high-priced veterans.
''I could care less about the scouts or trade rumors,'' Lee said. ''I've never cared about them. My goal is to go out there and give my team a chance to win. I'm in Philly and I want this team to win.''
The teams combined to hit 21 singles before Duvall launched a homer to straightaway center to give the Giants a 5-4 lead in the sixth. Pence's RBI single with two outs made it 6-4 and sent Lee to an early exit. Pence hit an RBI triple off Jeff Manship in the eighth.
''It's pretty cool to hit a homer against a guy like that,'' Duvall said.
Ryan Howard gave the Phillies a 4-3 lead in the fourth on a checked-swing single to left that chased Vogelsong. Kontos entered with runners on first and third, struck out Marlon Byrd and Domonic Brown and retired Cody Asche on a liner to right.
Jimmy Rollins gave the Phillies a 2-1 lead with a two-run single with the bases loaded and two outs in the second. Posey hit a two-run single to center to make it 3-2 in the third.
Gregor Blanco's RBI single to right in the second gave the Giants a 1-0 lead. Byrd threw out Michael Morse trying to score from second base on the play. Morse ran into catcher Cameron Rupp and was upended over the plate before being tagged out. Giants manager Bruce Bochy challenged the call, but a video review confirmed he was out.
Phillies manager Ryne Sandberg had a successful challenge in the seventh inning when replays showed Asche beat a throw to first for an infield single. The game ended with a challenge when Brown grounded out to third and a review upheld the call.
NOTES: The Giants signed three-time All-Star 2B Dan Uggla to a minor league contract. Uggla was released by the Braves last Friday. ''He's excited and we are, too,'' Bochy said. ''He'll get at-bats at Fresno and hopefully he can help us.'' ... The Giants put RHP Cain on the 15-day DL because of elbow inflammation. They placed 1B Belt on the seven-day DL because of a concussion. ... Pence leads the NL with 37 multi-hit games. ... RHP Roberto Hernandez (4-8, 4.22) goes for the Phillies on Tuesday night vs. RHP Yusmeiro Petit (3-3, 3.86).