SAN FRANCISCO -- If Tim Lincecum wants to win without an overpowering fastball, he knows he will have to find his way through games when he is nowhere near his best.
And he was nowhere near his best Friday night. And yet, he still won.
"He was bobbing and weaving out there the whole game," Giants manager Bruce Bochy said.
Lincecum (4-3) struck out four and walked six in six innings. He allowed five hits and also had two wild pitches, escaping trouble in nearly every inning.
Only 57 of Lincecum's 112 pitches were strikes.
"You've got to battle when you don't have your best stuff, your best command. And today was just that," Lincecum said. "It's kind of an ugly win, but I'll take it.
Joe Mauer and Chris Parmelee drove in Minnesota's only runs in the third.
Sandoval hit a three-run shot in the first, Hicks hit his eighth homer off Kyle Gibson (4-4) in the fourth and drove in another run on a flyout in the seventh.
Gibson gave up five runs and five hits in five innings, working quickly and in command for most of his 72-pitch outing. He struck out four and walked none.
"I really got beat on three pitches, which is the frustrating part," Gibson said.
San Francisco opened its six-game homestand with some pop at the plate and slick maneuvering on the mound.
Hunter Pence extended his hitting streak to 10 games with an infield single after Angel Pagan doubled leading off the first. Pence was originally ruled out, Bochy challenged the call and umpires overturned it after a 33-second video review.
Pagan was thrown out at home on Buster Posey's grounder, but not before third baseman Trevor Plouffe's throw pulled Brian Dozier off second on what would've been an inning-ending double play. Then, Sandoval sent the first pitch he saw over the brick wall in right to put the Giants ahead 3-0. It was Sandoval's fifth home run this season.
"I just focused and tried to calm myself down a little bit more," Sandoval said.
Mauer hit an RBI triple and Parmelee drove in another run for Minnesota in the third to slice San Francisco's lead to 3-2. In the bottom of the inning, Pagan tripled and scored for San Francisco after shortstop Eduardo Escobar couldn't corral Pence's grounder.
Despite his lack of command, Lincecum kept the Giants in control.
The two-time NL Cy Young Award winner, still searching for consistency as his fastball has faded in recent years, walked two and threw two wild pitches in the third without allowing a run. Sandoval fielded Gibson's grounder at third and threw out Escobar at the plate before Lincecum struck out Dozier to end the inning.
In the fifth, Lincecum loaded the bases before getting Escobar to hit a weak groundout to first. Lincecum's saved his smoothest inning for his final one, retiring the side in order before leaving to a standing ovation from the announced sellout crowd of 41,514.
Left-hander Jeremy Affeldt tossed a scoreless seventh for the Giants. After Javier Lopez allowed two baserunners in the eighth, Jean Machi got pinch-hitter Josmil Pinto to ground into a double-play before pitching a perfect ninth for the save.
"We were a little sloppy defensively and we missed plenty of opportunities to get some hits," Twins manager Ron Gardenhire said. "A rough start for us here, and that team over there knows how to take advantage of you."
NOTES: The Giants will wait until at least Saturday to decide if RHP Matt Cain, who strained his right hamstring Wednesday at Colorado, will make his next start Monday against the Chicago Cubs. Bochy said Cain "was bouncing around pretty good" in the clubhouse. ... Mauer and Posey, who have each won an MVP at catcher, both started at first base. ... Twins RHP Samuel Deduno (1-2, 3.53 ERA), originally slated to start Sunday, will take the mound on Saturday. Ricky Nolasco will pitch Sunday. ... Ryan Vogelsong (2-2, 3.62) goes for the Giants on Saturday and lefty Madison Bumgarner starts Sunday.