SAN FRANCISCO -

Francisco Liriano struck out a season-high 11 in seven innings to win consecutive starts for the first time this season and the Pittsburgh Pirates beat the Giants 3-1 on Tuesday at AT&T Park.

Josh Harrison hit a leadoff home run in the first inning and Travis Snider added a two-run shot in the second for the Pirates, who moved within one game of first-place Milwaukee in the NL Central.

A former minor-league prospect for the Giants traded to Minnesota for A.J. Pierzynski, Liriano (3-7) gave up a home run to Mike Morse but was otherwise stellar while leading the surging Pirates to their eighth win in 11 games. The left-hander allowed four hits, walked one and retired 18 of the final 21 hitters he faced.

San Francisco lost its sixth straight, matching its longest skid of the season.

Harrison hit a 3-2 pitch from Giants starter Tim Hudson off the facing off the brick wall in right field for his first career leadoff home run. Harrison is hitting .583 (7 for 12) with a double and three home runs over his past three games.

Snider hit his seventh homer after Ike Davis reached on an infield single leading off the second.

It was just enough to help the Pirates (57-49) move a season-high eight games over .500.

Mark Melancon worked the ninth for his 20th save.

Buster Posey had three of the Giants’ six hits, including a leadoff single in the ninth. Pablo Sandoval followed with a deep fly out to right before Melancon struck out Morse and pinch-hitter Travis Ishikawa.

Hudson (8-8) allowed six hits over seven innings and took his sixth loss in the last eight starts.

Cain to see specialist: Giants right-hander Matt Cain plans to meet with specialist Dr. James Andrews this week to get a second opinion on his injured elbow.

Cain flew to Florida on Tuesday where he will be examined by Andrews. Cain, who has been on the disabled list since July 21 due to inflammation in his pitching elbow, will rejoin the team in New York on Friday.

Giants manager Bruce Bochy said that having Cain get evaluated by Andrews is a precautionary move. He added that surgery has not yet been discussed.

Cain (2-7) has struggled all season. The one-time ace has a 4.18 ERA and has not pitched since July 9 when he went six innings to beat the A’s.

The Giants last week acquired pitcher Jake Peavy from Boston for two minor-league prospects.

ON DECK

Tim Lincecum (9-7) pitches the finale for the Giants on Wednesday. Charlie Morton (5-10) goes for the Pirates.