Huff hit a three-run homer, Buster Posey had a solo shot and San Francisco moved into first place in the division race with a 10-2 win over the Los Angeles Dodgers on Thursday night.

“It says a lot about this club and how hard they’ve been fighting,” manager Bruce Bochy said. “It’s going to be a tough race, we know it.”

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. The Giants are trying to end a six-year playoff drought.

“Hopefully we can stay there all the way until the end,” Sanchez said. “It feels good to be in first place. We’ve got a lot of games to go and we’ve got to keep playing like this if we’re going to finish first.”

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 just fair inside the left-field foul pole 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 Jonathan 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.

“They’re on a roll and swinging the bats,” Dodgers manager Joe Torre said. “Sanchez was terrific.”

Sanchez’s strikeouts were the second-most by a Giant this year. Tim Lincecum struck out 13 at Florida on May 4.

Sanchez has one motivation to keep throwing strikes: “I just want to win it and make the playoffs,” he said.

The Giants allowed an unearned run in the first, but Sanchez was unfazed and quickly found his groove.

“It seems like about a month now he’s been throwing strikes and getting ahead,” Huff said. “When he’s doing that, he’s one of the most dangerous guys on our staff.”

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.

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.