SAN FRANCISCO -- The San Francisco Giants finally got their offense going, and they needed it to survive another shaky performance from their bullpen.
"They just started swinging with I think more authority," Giants manager Bruce Bochy said.
The Giants had lost three in a row and Pittsburgh had won three straight.
Posey broke out of a 0-for-13 stretch with his second four-hit game in less than two weeks. All four hits came in the first four innings as the Giants built a 10-2 lead.
He's the first Giants player with four hits through the first four innings of a game since the team moved to San Francisco in 1958.
Posey and Alen Hanson each drove in three runs. McCutchen hit a leadoff homer and later drew four walks for a San Francisco team that batted .212 and averaged 2.7 runs over its previous six games.
"They were letting it go tonight," Bochy said. "It was good to see them have some success, I mean we've been shut down, we've been due for a game like this where we break it open, even though they came back and made it a game. "
Francisco Cervelli drove in five runs with three hits for the Pirates. His 11th home run of the season and fourth career grand slam, off reliever Pierce Johnson, closed Pittsburgh within 11-7 in the seventh inning.
Adeiny Hechavarria, playing his second game since being traded from Tampa Bay to Pittsburgh, went 2 for 2 with a home run.
Giants starter Derek Holland (6-8) gave up five runs in 6 1/3 innings.
A big night from the offense allowed him to be more aggressive.
"It's huge," Holland said. "The offense is putting in the work, and I'm little bit upset with myself. They put the runs up, I've got to keep the momentum on our side."
Clay Holmes (1-2) was tagged for seven runs in 2 2/3 innings in his third career start.
"Our command was pretty inconsistent throughout the evening," Pirates manager Clint Hurdle said. "Clayton was so good the last time out. His fastball command was off and that complicates things."
Giants third baseman Evan Longoria was hit in the back by a 97 mph fastball by Pirates reliever Kyle Crick in the bottom of the seventh. Longoria initially stayed in the game but was pulled in the top of the eighth. Longoria said he felt fine after the game, but wasn't certain about his playing status for Saturday's game.
"I don't think he had intent," Longoria said. "He threw a couple more to the backstop and almost hit (Joe Panik), he just obviously didn't have a very good feel for where the ball was going tonight."
Pirates OF Gregory Polanco struck out as a pinch-hitter. Manager Clint Hurdle said Polanco will get another rest day in Sunday's series finale.
Giants: 1B Brandon Belt (hyperextended right knee) will start a rehab assignment with Triple-A Sacramento on Saturday, manager Bruce Bochy said. If all goes well, Belt could join the team for next week's series against the Dodgers in Los Angeles, which starts Monday. ... RHP Johnny Cueto, who underwent Tommy John surgery earlier this month, was moved to the 60-day DL. RHP Casey Kelly was selected to the Giants' Major League roster in a corresponding move before Friday's game. ... RHP Derek Law was optioned to Triple-A Sacramento.
RHP Trevor Williams (9-8, 3.88 ERA) will pitch Saturday for the Pirates. He has a 2.25 ERA without a decision in two career starts against the Giants. LHP Ty Blach (6-6, 4.28) will pitch for the Giants.
More AP baseball: https://apnews.com/tag/MLBbaseball and https://twitter.com/AP-Sports
Lindor cranks his ninth HR with the Mets
Francisco Lindor provides the Mets with some vital insurance runs with a two-run shot in the second inning.
Rays stop 7-game skid, beat AL East-leading Red Sox 8-2
— Austin Meadows, Mike Zunino and Brandon Lowe homered to help the Tampa Bay Rays stop a seven-game losing streak by beating the AL East-leading Boston Red Sox 8-2 on Wednesday night.
Zunino crushes HR off Richards in second inning
Mike Zunino clobbers the ball in the second inning and celebrates with his teammates in the dugout afterwards.
Lowe's HR carries over center-field fence
Brandon Lowe extends the Rays' lead to seven runs after smashing this three-run dinger.
Ray helps Blue Jays win 4th straight by beating Marlins 3-1
— Robbie Ray allowed one run in six innings, and three relievers completed a five-hitter as the Toronto Blue Jays earned their fourth victory in a row, beating the Miami Marlins 3-1 Wednesday night to complete a two-game sweep.
Astros club 4 HRs, beat Orioles 13-0 for 10th straight win
— José Altuve silenced the booing fans at Camden Yards with a two-run homer, José Urquidy pitched seven innings of three-hit ball and the Houston Astros stretched their winning streak to 10 games by breezing past the Baltimore Orioles 13-0 Wednesday...