The Giants rallied from a 3-0 deficit to take a 5-3 lead into the bottom of the eighth but Pence tied it with a two-run drive off Armando Benitez. Lee then won it with his ninth home run of the season and the third game-winning homer of his career.
"We know what we have in this clubhouse is the ability to do a lot of damage and score a lot of runs," Lee said. "So we expect to score runs every day and do good every day."
Barry Bonds went 0-for-2 with two walks for the Giants and stayed stuck on 745 career homers, 10 shy of Aaron's career record. He hasn't homered at Minute Maid Park since opening day in 2004.
Lee went 4-for-4, scored four runs and finished with two RBI and Pence was 3-for-3 with three RBI for Houston, which won for the ninth time in 13 games. It was Houston's eighth come-from-behind win.
"It's a huge win. Those build momentum," said Pence, who has 12 RBI in his last nine games. "For the team to come back from being down after we jumped out to a lead shows some character."
San Francisco had been 15-2 when leading after seven, but reliever Jack Taschner gave up a one-out single to Lee in the eighth to fuel the rally. Luke Scott flew out and Benitez replaced Taschner to face Pence, a rookie who was called up on April 27.
Pence launched a 2-1 pitch into the left-field corner, just inside the foul pole to tie it. From the dugout, the Giants thought the ball was going to hook foul.
"He one-armed it," San Francisco manager Bruce Bochy said. "It's great for them, but it's a bad break for us. He didn't hit it good, but you don't have to hit it good in this park."
Already a hometown favorite, Pence came out of the dugout and tipped his helmet to answer a standing ovation.
"The only other one I had was in the minor leagues and I didn't really know what was going on and I missed it," Pence said. "This time, they told me I went out there too early but I was like, 'I'm not missing it.'"
Benitez, who hadn't blown a save all season, stayed in the game for the ninth and walked pinch-hitter Orlando Palmeiro. Backup catcher Brad Ausmus dropped a bunt to advance Palmeiro to second, but Benitez struck out Craig Biggio and Mike Lamb to force extra innings.
Sanchez (1-1) came on in the 10th and struck out Lance Berkman before Lee homered off the facade in left-center field. Fireworks boomed inside the park as Lee rounded the bases and the entire team mobbed him at home plate.
The Astros signed Lee in the offseason to a six-year, $100 million contract, and he's proven so far that he's worth the money. Lee has 37 RBI, tied for the NL lead with Milwaukee's J.J. Hardy, and is batting .520 (26-for-50) since May 2. Lee batted only .250 in April.
"Earlier in the year, I think that I was swinging too hard and trying to do too much," he said. "I was trying to make a statement, coming here and hit a three-run homer with nobody on. It was just stuff that was kind of taking away from the game."
Pence gave the Astros a 1-0 lead in the second inning with an RBI double off Matt Morris.
Williams led off the third with a surprising solo homer that sailed over Bonds' head in left. It was Williams' fourth career homer and his first since July 20, 2003.
Lee added a solo shot in the fourth. Morris had allowed only two homers in his first seven starts.
Williams yielded only four hits until the switch-hitting Winn led off the sixth with a drive to right. Fred Lewis, who hit for the cycle in Colorado on Sunday, followed with a single, but Rich Aurilia grounded to third baseman Lamb and Lewis was out on a fielder's choice.
Bonds grounded out before Durham tied it with a homer to right, his third of the season.
Pedro Feliz led off the Giants' seventh with a double to the right-field wall and Winn singled to give the Giants a 4-3 lead. Bengie Molina added an RBI single in the eighth off Astros reliever Rick White.
The Giants' bullpen had a 2.94 ERA since April 18, but blew a save for the fourth time this season.
Lee hit the game-winning homer on a fastball after Sanchez shook off Molina's signal for a changeup.
"I just went after him," Sanchez said. "I knew he was a good hitter, but I'm still going to go after him."
The Astros rallied to win for only the sixth time in 20 games against the Giants at Minute Maid Park.
- While pitching to Bonds in the sixth, Williams was called for a balk.
- The Astros haven't won a home series with the Giants since 1999. The Giants won five of six meetings last season and outscored the Astros 34-5 in a three-game series in Houston.
- Williams' homer was the first for an Astros pitcher since last Aug. 11, when Andy Pettitte hit the first of his career against San Diego's Chan Ho Park.
- Winn extended his career-best hitting streak to 14 games with a single in the first inning.