Jonathan Sanchez (11-8) struck out a career-high 12 as the Giants took a half-game lead on the Padres after San Diego lost 4-0 at St. Louis. San Francisco is in sole possession of first place for the first time since May 6.
Dodgers starter Ted Lilly (8-11) was done after 3 1-3 innings for his shortest outing of the season. This was just his third loss in nine starts since joining the Dodgers at the trade deadline.
Russ Mitchell homered for his first career hit leading off the fifth for Los Angeles. He had been 0 for 15.
Huff and Posey connected for back-to-back homers in the third, the seventh time the Giants have hit consecutive homers this season.
Jose Guillen added a two-run drive in the fifth to make it 8-2. It was his 18th home run of the season and second with the Giants. Guillen returned to the starting lineup after missing Wednesday's game with a painful neck. He underwent an MRI exam Thursday and said everything was fine.
Freddy Sanchez added a two-run double in the eighth.
All the offense helped Sanchez win his third straight decision. The left-hander, who has been one of the Giants' most reliable starters down the stretch, recorded his seventh career game with double-digit strikeouts and fourth of the season. He allowed four hits and one run in seven innings and didn't walk a batter for the second time in his 30 starts.
Sanchez's strikeouts were the second-most by a Giant this year. Tim Lincecum struck out 13 at Florida on May 4.
Lilly was tagged for five runs and seven hits, and he struck out three and walked one. He had been so reliable for Los Angeles every fifth day that manager Joe Torre said before the game, "Lilly's been such a savior for us in more ways than one."
Giants manager Bruce Bochy is using a leadoff man by committee in the absence of the injured Andres Torres, recovering from an emergency appendectomy Sunday. Edgar Renteria took on the job with a lefty starter going and had a triple among his four hits. Milwaukee starts left-hander Randy Wolf on Friday night, so Renteria will probably be in there again.
The Giants captured the season series with the Dodgers 10-8, San Francisco's first series victory against its rivals since going 10-9 in 2005. The teams open the 2011 season facing off for four games at Dodger Stadium from April 1-4, 2011.
Los Angeles finished up a 10-game road trip and returned home for a weekend series with the Rockies. Los Angeles faces divisional opponents the rest of the way.
Matt Kemp struck out in the sixth to match his career high of 153 also done in 2008.