Cole won for the first time in nearly a month, and the Pittsburgh Pirates beat San Francisco 4-3 Wednesday for their second straight win over the Giants.
Cole (3-2) beat Tim Lincecum for the second time in his 11-month major league career, allowing three runs and seven hits in eight innings with seven strikeouts and a walk. The No. 1 pick in the 2011 amateur draft, Cole had a fastball clocked at 95-96 mph to begin the game and was 97-98 over his final two innings.
''Really solid, solid effort for him,'' Pirates manager Clint Hurdle said. ''Pushing through the eighth inning, the middle of the order, was very impressive. He's capable of a lot of things out there. You saw the velocity stay at a much higher level today throughout the game, and actually his velocity played bigger later than it did earlier.''
Fill-in closer Mark Melancon worked a perfect ninth for his second save in three chances. Centerfielder Andrew McCutchen made a diving catch of Brandon Crawford's soft liner to left-center for the second out.
Pittsburgh has won four of six after a 1-7 slide, taking two of three in the series. San Francisco had won 10 of 11 before the Pirates' replay-aided walkoff win Tuesday. Pittsburgh scored all its runs over the first two innings Wednesday.
''We're starting to click on all cylinders now,'' said Pirates catcher Chris Stewart, who had two hits. ''The pitching is starting to come around, and we're starting to get those hits in those big situations that we weren't before''.
Ike Davis had three hits for the Pirates. Brandon Belt hit his ninth home run and drove in all three runs for San Francisco.
Cole had been 0-2 in four starts since winning his first two outings. He pitched eight innings for the second time this season, throwing 107 pitches, one shy of his season high.
Cole, who went 1 for 3 to maintain a .333 batting average, won his major league debut at home last June 11 against Lincecum, a two-time NL Cy Young Award winner.
Lincecum (2-2) allowed four runs, eight hits and two walks in four innings. Opponents are hitting .329 against him.
''I wasn't finishing my pitches, especially my secondary pitches,'' he said. ''When I got ahead in the count, the secondary pitchers were just rolling up there and had no bite on them. I'm the type of guy who's going to have to get guys to chase pitches, but I can't do that when I'm leaving balls up in the strike zone that are so hittable.''
McCutchen had a run-scoring single in the first and came around on Starling Marte's double. Travis Snider made it 4-1 with a two-run single in the second.
Belt homered on the first pitch he saw with two outs in the first, then hit a two-run double with two outs in the fifth. But Belt was thrown out at third on the play, ending the threat.
''That was a mistake,'' Giants manager Bruce Bochy said.
NOTES: 3B Pablo Sandoval was not in the starting lineup after sustaining what Bochy termed a sprain of his hand or thumb during the final play of Tuesday night's game. He pinch hit for Lincecum in the fifth and singled. ... Neil Walker had a second-inning single has has reached safely in all 15 home games he's played against San Francisco ... The Giants headed to Los Angeles for a four-game series against the Dodgers that starts Thursday. San Francisco's starter in the opener, RHP Ryan Vogelsong, has allowed one earned run over 13 innings in his past two starts. ... The Pirates host St. Louis this weekend in a series that includes the first ESPN Sunday night game in PNC Park's 14-year history.