Lincecum scattered seven hits and two runs over seven innings, Huff hit a go-ahead two-run double in the third inning and added a solo homer and the Giants held off a late rally to beat the Los Angeles Dodgers 6-5 on Friday night.
"We haven't played well in our division or against them and that's why we were doing all we could there at the end trying to get outs," said San Francisco manager Bruce Bochy, who used four relievers in the ninth inning when the Dodgers scored three times.
"The key for us is playing better in our division because they've pretty much had their way with us at times, just like San Diego. It's critical we play better against those teams."
The Giants pulled within 2½ games of the first-place Padres in the NL West and maintained their lead over St. Louis and Philadelphia in the wild-card chase.
They did it behind another big game from Huff and a new, possibly improved Lincecum.
Huff, who passed the 1,500-hit mark earlier this week, singled and scored on Pat Burrell's line drive double down the third base line in the sixth when the Giants chased Dodgers starter Carlos Monasterios (3-3).
The San Francisco left fielder later made a running catch on Jamey Carroll's deep fly ball, bringing the sellout crowd at AT&T Park to its feet. They rose again when Huff hit his team-leading 20th homer off reliever Jeff Weaver with two outs in the seventh.
"They almost had our number again," Huff said. "We closed it out fortunately. The bottom line is we won the game and hopefully we can come back tomorrow and do it again.
Lincecum, the reigning two-time NL Cy Young winner, made a slight alteration to his delivery during his last bullpen session earlier this week. The new look has the right-hander bringing both of his hands higher over his head during his wind-up than he had previously been doing.
"Lately I've had a tougher timing issue out of my wind-up keeping myself over the mound and going toward home plate before my arm could get to the right spot," Lincecum said. "It's something I did before (in college) when I was dealing with a control issue. I figured I'd go back to it and it felt pretty comfortable considering I haven't thrown with it all year."
Lincecum struck out nine and walked two while winning for the first time since July 15.
The Dodgers, seeing their playoff hopes dimming, were reportedly talking with the Chicago Cubs about the possibility of acquiring left-hander Ted Lilly to bolster their pitching staff. If a deal is made, it would be the second by Los Angeles this week after the team traded for leadoff hitter Scott Podsednik.
"I thought we showed a lot of fight and if we keep playing like this, then things will go our way eventually," Dodgers catcher Russell Martin said. "I think our mindset's going to be we're going to have to start our playoffs a little earlier this year if we want to get there. That should be our mindset every day."
The Giants, who blew a seven-run lead before holding on to beat Florida on Thursday, nearly let a four-run advantage get away against the Dodgers.
Los Angeles scored three times in the ninth inning when the Giants used four relievers, including left-handed starter Jonathan Sanchez. Podsednik had an RBI triple and scored on a wild pitch, and Matt Kemp singled to drive in Rafael Furcal and make it 6-5 before Chris Ray got Casey Blake to ground out to end the game.
It's Ray's second save this season, his first with San Francisco.
Juan Uribe's solo home run in the second inning brought chants of "Ooo-Ree-Bay" that quickly turned into "Beat L.A., Beat L.A." It was Uribe's third homer in seven games.
The Dodgers, who fell 4 1/2 games behind the Giants in the NL wild card race, lost their third straight and are 5-10 since the All-Star game.
Earlier in the day Dodgers manager Joe Torre talked about the possibility of adding another player before the trade deadline. Indications are that it likely will be Lilly, who was a 23rd-round draft pick of Los Angeles in 1996.
While Lilly would fill a hole on the Dodgers' pitching staff, he won't be able to do much to help an ailing offense that had produced just 14 runs in eight games before Friday.
"Our pitchers have been doing well and we're putting a lot of strain on them," Torre said before the game. "We're not doing a good job right now."
It didn't help facing Lincecum, who also gave the Giants a lift after struggling early. He hit Blake with pitches twice, allowed an RBI single to Russell Martin in the second and gave up a home run to Furcal leading off the third.
Lincecum settled down after that and retired nine of the final 11 batters he faced while notching nine strikeouts. That was in sharp contrast to his previous outing against the Dodgers when Lincecum was roughed up for five runs in 4 2/3 innings.
Monasterios, who will likely head back to the bullpen if the trade for Lilly goes through, lasted only five innings and gave up four runs.
Furcal homered to straightaway center leading off the third to give Los Angeles a 2-1 lead. The All-Star shortstop, who hasn't had more than nine home runs in a season since 2006 when he matched his career-high of 15, also doubled in the fourth and was thrown out trying to stretch it into a triple.
Dodgers OF Manny Ramirez, on the DL with a strained right calf, will rejoin the team in Los Angeles next week to discuss the next step in his rehab. "It seems like the leg woes are disappearing," Torre said. "Everything is going forward." ... The Giants will honor former players IF Rich Aurilia and LHP Shawn Estes on Saturday, placing commemorative plaques of both on the team's Wall of Fame. ... San Francisco is 9-0 this season when wearing their orange jerseys.