Garrett Jones gets a high-five from Gaby Sanchez after hitting a home run against the San Francisco Giants during the second inning in San Francisco, Thursday, Aug. 22, 2013. Photo: George Nikitin/AP
SAN FRANCISCO (AP) -- Clint Hurdle is never sure how the Pittsburgh Pirates will win.
On a night breakthrough pitcher Jeff Locke struggled with his command, the offense delivered all through the lineup.
Garrett Jones and Jordy Mercer homered, Jose Tabata hit a three-run double, and the NL Central-leading Pirates beat the San Francisco Giants 10-5 on Thursday night.
Pedro Alvarez hit a go-ahead, two-run double to start a seven-run fifth and matched his career high for RBIs in a season with 85. Russell Martin and Gaby Sanchez added sacrifice flies and Tabata doubled in his second plate appearance of the inning.
''You can't write this stuff up. It's a great game, it's a crazy game, it makes you laugh, it makes you cry,'' Hurdle said. ''This team, we believe in us and whatever it's going to take. We don't always know how it's going to happen but we're going to keep playing and covering each other's back and keep having fun along with it. Sometimes that's a little bit more of a challenge than other times.''
Marco Scutaro had a tying two-run single in the fourth for San Francisco after scoring in the third on Buster Posey's sacrifice fly.
Giants right-hander Matt Cain departed after getting hit on his pitching arm on a line drive by Sanchez. X-rays on Cain's bruised forearm were negative.
Jones' 12th homer leading off the second was a splash-hit drive into McCovey Cove beyond the right-field wall. It was the 28th at AT&T Park by an opponent and second by a Pirates player. Adam LaRoche hit one on Aug. 11, 2007, against Tim Lincecum.
''It's definitely a step forward in the right direction,'' said Jones, batting .239. ''I felt better up there timing wise. I just need to do it consistently.''
Cain was hit when Sanchez led off the fourth with a groundout. Trainer Dave Groeschner and manager Bruce Bochy hustled out to check on the pitcher, who walked off the mound on his own moments later.
Manager Bruce Bochy expected to know more about Cain's condition Friday.
''That ball was smoked. It caught him flush. He has a pretty good contusion. He's really sore. We'll know more tomorrow. We're not going to take any chances.''
Cain allowed three runs and seven hits in 3 1-3 innings. Guillermo Moscoso (1-2) relieved with the Giants trailing 3-1.
Cain, who had been on a nice roll since the All-Star break, threw 64 pitches, 40 for strikes.
''It caught me pretty good. It didn't feel right, right off the bat,'' he said. ''Like the time in 2009, I had the feeling it wasn't very good.''
Tabata added a pair of singles for his third three-hit game in August.
Jeanmar Gomez (3-0) pitched three scoreless innings of relief for the win following Jeff Locke, who allowed three runs, five hits and four walks in four innings.
On a day the Giants lost outfielder Andres Torres perhaps for the season to a strained left Achilles tendon, the defending World Series champs were dealt another blow with the early exit for Cain. San Francisco was outscored 21-4 in a losing three-game series against the Red Sox - including 12-1 in Wednesday's finale.
It wasn't much better in the opener of a four-game series with the Pirates. Brandon Crawford added a two-run double in the eighth for San Francisco.
''It's definitely not what we had planned with Pittsburgh coming in,'' Cain said.
Third baseman Pablo Sandoval returned to the Giants' lineup after missing two games with a sore back. He grounded into a double play in the second and wound up 1 for 3 with a walk.
NOTES: Pirates GM Neal Huntington said LHP Wandy Rodriguez (forearm tightness) felt pain during his simulated game and will be examined by Dr. James Andrews early next week. ... Bochy said struggling LHP Barry Zito (4-9, 5.63 ERA) is scheduled to make his next start. ''We're keeping the guys in the rotation where they're at,'' Bochy said. ... Pirates RH closer Jason Grilli, nursing a strained tendon in his throwing arm, threw a 25-pitch bullpen and is scheduled for another side session Sunday before a likely rehab outing. ''Another good day for Jason,'' manager Clint Hurdle said. ''We'll see how he bounces back tomorrow.'' ... Hurdle believes OF Starling Marte is close to returning and won't need a DL stint. He missed his fourth straight game because of a bruise on his right hand after getting stepped on during a headfirst slide against Arizona on Sunday. ''I think Marte is right on the edge of coming back,'' Hurdle said. ''He's closing in on that - return to play.'' ... The Giants are 9-22 vs. the NL Central.