Houston came back from a 6-0 deficit to take three of four from the Giants, its first series win at San Francisco since a three-game sweep in September 2001.
Berkman also hit a two-run single and is riding a 14-game hitting streak. He went 7-for-15 (.467) with three homers and seven RBIs during the series.
Pinch-hitter Darin Erstad hit a tying, three-run homer in the eighth and Carlos Lee also homered in the inning off Tyler Walker, who faltered on his 32nd birthday. Berkman connected off Vinnie Chulk (0-2) for the first splash-hit homer by an Astro and the 16th by a Giants opponent.
Barry Bonds, the indicted home run king, hit 35 into the water beyond the right-field fence.
Tim Byrdak (2-0) got two outs for the win and Jose Valverde struck out two in a perfect ninth for his 11th save in 14 opportunities. Byrdak hasn't allowed a run in 11 outings this year.
Erstad's drive to the right-field arcade marked his first career pinch-hit homer and the first for the Astros this season. It also spoiled a strong start by San Francisco's Tim Lincecum.
Randy Winn doubled twice among his three hits and scored two runs. Aaron Rowand drove in two runs for the Giants, who got five straight hits off starter Chris Sampson to start the third on an unusually hot spring day in the Bay Area. It was 95 degrees at first pitch -- the second-hottest day in the ballpark's 9-year history and the third game when the temperature reached 90.
Omar Vizquel singled in his first three at-bats to give him 2,606 hits, moving him past Tim Raines for seventh place among switch-hitters. John Bowker hit a two-run double and added a sacrifice fly for the Giants.
Houston's Hunter Pence extended his hitting streak to 13 games with a double in the fourth, then Berkman followed with his two-run single. Mark Loretta also had an RBI single in the inning.
Alex Hinshaw, called up from Triple-A Fresno earlier in the day, relieved Walker to make his major league debut and struck out Michael Bourn before allowing a single to Kaz Matsui and giving way to Chulk.
Lincecum walked Berkman to start the second but that was his only baserunner until Matsui's single to start the fourth. Lincecum struck out 10 for his fourth career game with 10 or more Ks and second this year. He allowed three runs on five hits and walked three in six innings.
Rowand's high chopper in the first got past shortstop Loretta for an error and an RBI, allowing Vizquel to score from third for a 1-0 lead. Regular starting shortstop Miguel Tejada took his first day off of the season for Houston before pinch-hitting in the ninth.
The Astros will conclude their season-long, 10-game road trip with three interleague games at Texas starting Friday. Notes:@ Astros reliever Geoff Geary left with a strained right groin. ... Houston stole three bases, including the seventh of the year by Berkman, to extend its major league lead to 45. ... Vizquel had three or more hits for the 176th time in his 20-year big league career. ... Houston 3B Ty Wigginton was held out of the lineup for the third straight game after getting hit in the left ribcage area Monday, but is expected to return Friday.