Updated

San Francisco, CA (SportsNetwork.com) - Gregor Blanco had three hits and two RBI and the San Francisco Giants beat the Pittsburgh Pirates 7-5 in the finale of a three-game series Wednesday to snap a six-game losing streak.

Blanco's hits included a game-tying RBI single in a two-run seventh inning that helped the Giants salvage a 1-5 homestand. They had scored just six total runs during their six-game losing streak.

Giants manager Bruce Bochy said the team had meetings during the skid, but all the meetings in the world don't matter if you don't perform well.

"This was a huge game, no question about it. I think we can all eat solid food now for a while," Bochy said. "To play like that at home isn't fun for these guys but they grinded hard today and put the ball in play. A lot of those balls weren't hit hard, but things can happen."

San Francisco catcher Andrew Susac got his first major-league hit on an RBI single and Jean Machi (6-0) got six outs to earn the win.

Josh Harrison and Jordy Mercer each hit a two-run homer off Giants starter Tim Lincecum but the Pirates had a three-game winning streak snapped.

Lincecum got the quick hook in his shortest start in more than two years. The two-time Cy Young Award winner gave up five runs, five hits and three walks and was pulled with one out in the fourth.

Charlie Morton went five innings for Pittsburgh and was in line for his first win in five starts despite giving up four runs on nine hits and three walks.

Machi was on the mound in the sixth when poor baserunning by the Pirates allowed the Giants to turn a bizarre inning-ending double play on a walk -- yes, a walk.

Travis Snider was caught far off second base after Chris Stewart walked and was tagged out in a rundown between second and third. So was Gaby Sanchez, who had left third base headed for home.

"We got a break. We were in a pretty tough spot," Bochy said. "It probably saved us. (Snider) must have thought the bases were loaded."

Said Snider, "That was a 100-percent mental error, unfortunately at an inopportune time for us."

An inning later, the Giants scored twice to take a 6-5 lead.

Michael Morse got the rally started with a walk off Justin Wilson (3-2). He went to second on Joe Panik's single and pinch-runner Juan Perez scored on Blanco's single to tie the game.

The go-ahead run came with Susac batting when catcher Stewart let a pitch go off his glove for a passed ball, then threw wildly to Wilson covering home. Pablo Sandoval made it 7-5 with an RBI single in the eighth inning.

Six straight batters reached base against Morton in a three-run first inning on four singles and two walks. Morse hit an RBI single with the bases loaded, Panik walked to force in a run and Blanco had a bases-loaded hit.

Neil Walker scored Pittsburgh's first run on a ground out in the second inning after leading off with a double and going to third on Lincecum's wild pitch.

Harrison drove an 0-1 slider over the wall in left-center field for his ninth homer of the season after Morton drew a leadoff walk in the third.

Susac's first career hit was an RBI single with the bases loaded in the bottom of the third that gave the Giants a 4-3 lead. But Mercer's seventh homer of the season, a two-run blast to left in the fourth, moved Pittsburgh in front.

Game Notes

It was Lincecum's shortest outing as a starter since throwing 3 1/3 innings in back-to-back starts on July 3 and 8, 2012 ... Morton is winless (0-1) in his last five starts and the team is 2-3 ... The Pirates will finish 10-game road trip with four games against Arizona starting Thursday ... The Dodgers start a 10-game road trip on Friday in New York against the Mets ... The Pirates won the season series against the Giants 4-2.