Lincecum (9-5) tossed seven shutout innings and allowed three hits while walking two and striking out six. He has been on a roll of late, having won four straight -- one of them a no-hitter -- and over that span, he has allowed just one run in 30 1/3 innings.
"Timmy's really been a shot in the arm for us," Giants manager Bruce Bochy said. "He's been the stopper here through these tough times. He's gotten us back on track it seems like every start, and it's nice having a guy in the rotation doing that for you."
The Giants gave Lincecum some early run support.
After Brandon Belt singled off Mike Bolsinger with one out in the first, Pablo Sandoval hit a cut fastball over the wall in right to give San Francisco a 2-0 lead.
"They got on us early and Lincecum was throwing a tough game, so it didn't work well for us at all," Gibson said.
Bolsinger (1-6) found himself immediately in trouble again in the second, allowing a leadoff single to Tyler Colvin and walking Joe Panik.
Brandon Crawford followed with an RBI single, and Lincecum helped himself out with a safety-squeeze bunt that scored Panik and gave the Giants a 4-0 lead.
"He just can't make pitches," Gibson said of Bolsinger. "Too many pitches in the middle of the plate. He's not commanding any of his pitches with regularity, and [when] they're in the middle of the plate, they're going to make you pay for it which they did tonight."
It was the second straight poor outing by Bolsinger, who allowed seven runs (five earned) while lasting just 3 2/3 innings against the Braves in his last start.
"The funny thing was, I was actually feeling kind of good," Bolsinger said of Friday night. "That last game in Atlanta, I can sit here and tell you that was a horrible outing. But this one, I'm almost scratching my head because I felt like I was throwing good pitches. That one to Sandoval, that was a good pitch and he just hit it out. I don't know. It was an interesting game."
The win was Lincecum's first against the D-backs since Aug. 30, 2013. In his previous three starts against Arizona, he allowed 15 earned runs over 16 innings.
Not even Paul Goldschmidt could solve Lincecum.
The D-backs first baseman entered the game 15-for-31 in his career against Lincecum with seven homers, but was 0-for-2 with a walk against Lincecum on Friday.
"I just tried to make him not too big in my mind," Lincecum said. "I know he's hurt me in the past, but those things kind of bite you in the butt when you think about them too much. I thought if I stick to my game plan and the way I want to get him out, things are going to turn out for the best, and I was able to execute my pitch plan as best as I can."