Updated

Pittsburgh, PA (SportsNetwork.com) - Hunter Pence scored the go-ahead run in the top of the 13th inning on Jared Hughes' throwing error to send the San Francisco Giants to an 11-10 triumph over the Pittsburgh Pirates in the opener of a three-game series at PNC Park.

Pence scored the tying run in the ninth on Buster Posey's single before working a one-out walk off Hughes in the 13th inning.

Hughes (1-1) then plunked Juan Perez before Jean Machi followed with a bunt down the third-base line. Hughes fielded the bunt cleanly, but his throw short-hopped first baseman Ike Davis and skipped high in the air, allowing Pence to race home for the deciding run.

Sergio Romo worked around a leadoff hit-by-pitch in the bottom of the frame to nail down his 10th save of the season, while Machi (5-0) picked up the win after spinning two scoreless innings in relief.

Pence finished 3-for-6 with four runs scored, Hector Sanchez had four hits and three RBI, and Posey supplied three hits, two RBI and scored three times for the Giants, who have won six straight and 10 of their last 11 games.

"It's about playing hard. It's about competing and never giving up," Pence said. "That's the attitude we have here and we're going to continue to do that."

Pedro Alvarez launched a three-run homer and drove in four runs, while Andrew McCutchen collected four hits and scored twice for the Pirates, who have lost two straight and five of their last seven games.

"We put some hits up on the board tonight, put some runs up on the board so that's pretty much all you can ask for," McCutchen said. "We just gotta show up tomorrow and try to do it again but just try to be on the winning side this time."

Pittsburgh lead 8-2 after scoring four runs in the third and four more in the fifth, but the Giants responded with a five-run sixth inning to cut into the margin.

Angel Pagan, Pence and Posey opened the frame with three straight singles to push a run across before Sanchez followed a Michael Morse strikeout with a single to left to plate Pence.

Bryan Morris then replaced Pittsburgh starter Jeff Locke and served up a single to Pablo Sandoval to load the bases for Brandon Hicks, who scorched a double to left to score Posey and Sanchez.

Brandon Crawford's sacrifice fly brought the visitors within 8-7, but Neil Walker notched an RBI groundout in the home half to make it 9-7.

In the seventh, Morse stroked an RBI double and Sanchez followed with a run- scoring single to tie the game, but Jose Tabata came through with a two-out, pinch-hit single in the home half to score Davis for a 10-9 lead.

With runners on second and third with two away in the frame, Tabata slapped a grounder back up the middle. Crawford made a diving stop on the play, and from his stomach, flipped the ball with his glove to Hicks at second base. Crawford's flip was off line and forced Hicks to dive for the ball, allowing Davis to score from second for a one-run lead.

Mark Melancon tried to protect Pittsburgh's slim edge in the ninth, but Pence smacked a leadoff single and moved to second on a wild pitch before scoring on Posey's single to right to force extra innings.

Early on, Morse's RBI double and Sanchez's run-scoring single staked San Francisco to a 2-0 lead in the first, but Walker ripped an RBI single in the third before Alvarez followed two batters later with a three-run homer to straightaway center field.

Pittsburgh added to its lead in the fifth, as McCutchen ripped a one-out double and scored when Alvarez followed with a single. Starling Marte then doubled before San Francisco starter Yusmeiro Petit intentionally walked Davis.

Jake Dunning took over on the mound and uncorked a pair of wild pitches around a walk to Tony Sanchez to plate two more runs. Clint Barmes' sac fly pushed Pittsburgh's lead to 8-2 after five frames.

Game Notes

Marte stole two bases and has swiped 11 consecutive bases. He's been successful 16 times in his last 17 attempts dating back to last season ... San Francisco improved to 16-1 when scoring first ... The Giants' streak of 11 straight games with a homer was snapped in the win ... Petit allowed eight runs on nine hits in 4 1/3 innings. He got the start in place of Matt Cain, who was placed on the 15-day disabled list Sunday with a cut on his right index finger ... Locke made his first start of the season after beginning the season at Triple-A Indianapolis. He allowed six runs on eight hits over 5 1/3 frames ... Pittsburgh finished 4-for-15 with runners in scoring position.