"I'll take it," Posey said. "Hopefully we can build on this moving forward. We got hits. We got hits with guys in scoring position and we had second and third right out of the chute. Those guys set the table."
Lincecum pitched into the sixth inning after two rocky starts for his first win in more than two weeks. The former two-time NL Cy Young winner walked four but struck out eight and pitched out of trouble in back-to-back innings before giving way to the bullpen.
"The early runs give you a lift and you don't have to worry about making a mistake," Lincecum said. "They give some leeway but it was still a little frustrating not being able to go deeper. I has trouble locating the fastball but stayed aggressive in the strike zone."
The Giants did most of the damage in the first inning when they batted around and scored four times off Pirates starter Francisco Liriano (14-6).
"That was good for the whole team," Giants catcher Hector Sanchez said. "It helped us all feel more comfortable."
The Giants chased Liriano after the fourth but added on against the Pirates bullpen. Sanchez was hit by a pitch with one out in the fifth and scored on a wild pitch by reliever Jared Hughes, making it 5-1.
Lincecum (7-13) made it stand up. He breezed through the first three innings then walked the first two hitters in the fourth. He quickly recovered and got Andrew McCutchen to fly out then struck out Pedro Alvarez and Garrett Jones.
"The first five and six innings I'm a fan and I get to watch him do his thing," said Giants closer Sergio Romo, who pitched the ninth for his 31st save. "Tim has been impressive all the time he's been here and watching him go through the ups and downs makes me appreciate him all that much more."
NOTES: Giants LHP Jeremy Affeldt (groin strain) threw off a mound and could begin a rehab assignment as early as next week. ... Sandoval is 15 for 38 (.395) with nine RBIs in his last 11 games. ... RHP Ryan Vogelsong (2-4, 6.29) starts for the fourth time since coming off the DL. He's 1-3 in four starts against his former team.
Copyright 2013 by The Associated Press
This story is from ESPN.com's automated news wire. Wire index
MORE MLB HEADLINES
- Royals' Hochevar needs Tommy John surgery
- Report: D-backs, Perez agree to $4.25M deal
- Nats' Fister held out with elbow inflammation
- Padres' Maybin to avoid surgery on biceps
MOST SENT STORIES ON ESPN.COM
- MLB Home
- AL East
- Baltimore Orioles
- Boston Red Sox
- New York Yankees
- Tampa Bay Rays
- Toronto Blue Jays
- AL Central
- Chicago White Sox
- Cleveland Indians
- Detroit Tigers
- Kansas City Royals
- Minnesota Twins
- AL West
- Houston Astros
- Los Angeles Angels
- Oakland Athletics
- Seattle Mariners
- Texas Rangers
- Fantasy: Sign up!
- Spring blog