SAN FRANCISCO -- Buster Posey's broken-bat single in the first inning was all the proof the Giants needed that this was going to be their night.
Posey had three hits and drove in a run in helping the Giants end a three-game losing streak with a 6-3 victory over the Pirates on Saturday night at AT&T Park.
On Friday night, Posey drove a ball to the deepest part of center field leading off the bottom of the ninth only to watch it fall into Andrew McCutchen's glove.
"Nothing makes up for that," said Posey, who added of the broken-bat single, "I'll take it."
Tim Lincecum showed his good self long enough to give the Giants a much needed lift. He took a shutout into the fifth inning after escaping a tough spot in the fourth.
Lincecum acknowledged that the early advantage gave him some breathing room, even though he thought striking out the side in the second was just a coincidence.
"The early runs give you a lift," Lincecum said. "They made a big difference. I didn't have to be so fine and didn't have to worry about making a mistake."
Lincecum was supported by just 2.42 runs per game over his previous 17 outings and the Giants have averaged a mere 3.37 runs at home, the lowest in the Majors.
At least for one night, that all changed, as the Giants improved to 13-3 over their past 16 games when scoring at least four runs.
"We got hits and we got hits with runners in scoring position," Posey said. "We had runners on second and third right out of the chute. Those guys set the table for us."
Even Pirates manager Clint Hurdle had to be shaking his head about that.
"That first inning just goes to show you," Hurdle said. "It's not how hard the ball is hit, it's where. Just an off day."
Pablo Sandoval drove in two runs and Gregor Blanco and Brett Pill each drove in a run as the Giants scored four runs in the first inning.
"It feels good," Posey said. "Hopefully we can build on this moving forward."
Lincecum (7-13) won for the second time in seven starts since his no-hitter against the Padres in San Diego on July 13. He allowed three runs on three hits in 5 1/3 innings. He walked four and struck out eight.
"I was still a little frustrated with myself," Lincecum said. "I had trouble locating my fastball and wasn't able to get deeper into the game."
He now has 1,482 strikeouts, the third-most all-time of any pitcher through seven seasons.
Lincecum walked the first batters he faced in the fourth but then retired McCutchen, who had his 10-game hitting streak against the Giants snapped, and struck out two to end the threat.
"I'm a fan for the first five or six innings and I get to watch these guys do their thing," said Giants closer Sergio Romo, who recorded his 31st save with a scoreless ninth. "Tim has been very impressive all through his time here. Everybody has their ups and downs, and seeing him keep battling makes me appreciate him that much more."
Giants manager Bruce Bochy said one of the key moments of the game was when left-hander Javier Lopez came in to face cleanup hitter Pedro Alvarez with two runners on in the seventh.
"He made good pitches with the game on the line," Bochy said. "He saved the game for us at that point."
Rick Eymer is a contributor to MLB.com. This story was not subject to the approval of Major League Baseball or its clubs.