Angel Pagan added an RBI single and drew a bases-loaded walk to back Lincecum (3-8) as the Giants moved into a first-place tie in the NL West with just their second sweep of the season - and the first time in franchise history shutting out the Dodgers in a three-game series spanning 123 seasons.
Lincecum struck out eight and walked two while outpitching Chad Billingsley (4-7). The two-time NL Cy Young Award winner ended a career-long 10-start winless stretch in which he went a career-worst 0-6.
His victory came one day shy of two months after his last win, April 28 against San Diego.
The Freak got focused, and he just plain got mad about his poor pitching. This outstanding outing helped the Giants get back to first place for the first time since last Aug. 9.
Facing a depleted Dodgers lineup didn't hurt. Already missing All-Star Matt Kemp, the Dodgers lost Andre Ethier after one at-bat to a left oblique injury.
Lincecum struck out two in a 1-2-3 second, and calmly punched his pitching hand into his glove as he walked from the mound back to the dugout. He also had gone 0-4 in his previous six starts against the Dodgers since his last victory on July 30, 2010.
The Dodgers were swept in the Bay Area for the second time in as many weeks after losing three straight at Oakland from June 19-21, scoring two total runs over the six games.
Melky Cabrera had an RBI double and Brandon Crawford tripled among his three hits in San Francisco's first three-game sweep of the Dodgers at AT&T Park since July 30-Aug. 1, 2010.
Pitching to cheers of "Come on, Timmy!" Lincecum also made a run-saving play that drew a standing ovation in the third.
After Billingsley doubled off the wall in center for his sixth hit in 25 at-bats this season, he moved to third on a wild pitch. Lincecum threw another wild pitch that got past catcher Hector Sanchez and reached the backstop. The pitcher covered home, blocked the plate and tagged out Billingsley. His glove was knocked loose, but Lincecum held onto it and made the play with his left hand.
Lincecum allowed only one more baserunner past first. Sergio Romo recorded the final four outs for his fourth save in as many tries.
Lincecum came to the plate to roars from the sellout crowd of 42,245 in the third and hit a one-out single down the left-field line. He scored on Cabrera's double.
Buster Posey then walked to load the bases and Pagan walked to force home a run, which brought pitching coach Rick Honeycutt to the mound for a visit with Billingsley.
Lincecum, who settled down Friday at Oakland after falling behind 3-0 in the first inning and showed positive signs the next four, ran his scoreless innings streak to 12.
Manager Bruce Bochy visited Lincecum after a seventh-inning walk to A.J. Ellis put runners on first and second with one out, but drew cheers when Lincecum stayed in the game to retire the next two batters in order.
He was caught for the second straight start by Sanchez.
The catcher landed hard on his left arm while making a diving catch of a foul popup by Herrera for the first out in the fourth. Bochy and athletic trainer Dave Groeschner came out, but Sanchez stayed in the game.
Lincecum struck out Dee Gordon to start the game, then allowed a single to Jerry Hairston and walked Andre Ethier. He then got Juan Rivera to ground into an inning-double play.
Ethier was removed before the bottom of the first after injuring his left oblique muscle, apparently while sliding into second on the double-play ball.
Billingsley lost his third straight start. He was tagged for three runs on nine hits in six innings.