Lincecum pitched himself in and out of trouble for six innings as San Francisco beat the Minnesota Twins, 6-2.
"It's huge to score three runs that early," Lincecum said. "That always helps."
Sandoval gave the Giants a 3-0 lead in the first inning when he hopped all over Kyle Gibson's first pitch for a home run.
"I was ready for anything," Sandoval said. "I'm just focused and not trying to do too much. I just try to get a good pitch. I feel better because we're winning."
Brandon Hicks also hit a home run and drove in two runs, Angel Pagan collected two hits and Hunter Pence added an RBI as the Giants won their third of the past four completed games.
"We kept saying he always has the ability to get the good part of the bat on the ball," Giants manager Bruce Bochy said of Sandoval. "We need him, especially since [Brandon] Belt went down."
Lincecum (4-3) walked a season-high six and allowed five hits but managed to avoid a big inning by getting key outs. He gave up two runs and struck out four while throwing 112 pitches.
"He worked hard for this one," Bochy said. "He was bobbing and weaving out there the whole game. That's a lot of pitches but the kid found a way to make pitches when he had to."
Lincecum said he could never remember a winning start where he threw more balls than strikes after six innings. He threw 55 balls and 57 strikes all told.
"You have to battle when you have less than your best stuff," Lincecum said. "The defense played great behind me and the offense was going. It was an ugly win but I'll take it."
Sandoval's home run followed some deception on the basepaths by Pagan, who doubled to open the first and went to third on a wild pitch.
Pence hit a grounder to third baseman Trevor Plouffe, who hesitated throwing to first when Pagan faked a move home. That led to Pence extending his hitting streak to 10 games on the infield single after a video review reversed an initial out call.
Buster Posey also hit a grounder to third base in the next at-bat. This time, when Plouffe threw to second, Pagan broke for the plate and was eventually tagged out in a rundown, but not before the Giants wound up with runners on second and third for Sandoval.
"We caught a break when they had to come off the bag at second or that's a double play," Bochy said.
Minnesota, which stranded 10 runners, scored twice in the third but the Giants added a run on Pence's infield grounder in the bottom of the third.
"With good pitchers like that, they figure out how to get outs when they need to," Twins catcher Kurt Suzuki said. "Obviously, Lincecum, he knows what he's doing out there and what he's got to do to get guys out. He gets in a situation like that and sometimes he gets better."
Hicks homered in the fourth and added a sacrifice fly in the seventh.
"We're just playing good, solid baseball," Posey said.
Minnesota manager Ron Gardenhire acknowledged that his team was slightly less than solid.
"We know the lefty's coming up there and we know what we're supposed to do," Gardenhire said. "[Gibson] just misfired one right down the middle and a guy hit a three-run homer. That was pretty disappointing. We were a little sloppy defensively and we missed plenty of opportunities."
Jean Machi recorded his second save of the season by getting the final five outs. The right-hander saw his ERA dip to 0.37.
"He's got swing-and-miss stuff," Posey said. "He can also induce grounders. He's a big weapon."