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.
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 in the seventh.
Gibson gave up five runs and five hits in five innings, working quickly and in command for all but the two homers. He struck out four and walked none.
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, Giants manager Bruce Bochy challenged the call and umpires overturned it after a 33-second video review.
After Pagan was thrown out at home on Buster Posey's grounder, 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.
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 Brian 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.
Only 57 of Lincecum's 112 pitches were strikes.
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.
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.