PITTSBURGH — The San Francisco Giants' recent run of success hasn't surprised Brandon Belt.

Belt also wasn't surprised when he helped continue that success Sunday.

Trailing 2-0, Belt started San Francisco's comeback with an RBI single in a three-run seventh inning, then added a two-run homer in the eighth as the Giants beat the Pittsburgh Pirates 5-3 Sunday at PNC Park for their season-high sixth straight win.

"I think there's a confidence and expectation to win now," Belt said. "Whereas before, I don't think we had that. It actually might have been the opposite. Not sure what triggered it, but this is the way we feel we should've been playing the whole time. This is how our team should be playing."

Jordy Mercer's two-run homer in the third off Jeff Samardzija (4-9) put the Pirates ahead.

Trevor Williams took a two-hit shutout into the seventh, when Hunter Pence walked leading off and Buster Posey doubled. Belt and Brandon Crawford hit consecutive run-scoring singles off left-hander Tony Watson (4-2), and Kelby Tomlinson's sacrifice fly gave San Francisco a 3-2 lead.

Belt homered in the eighth off Edgar Santana, his 16th this season.

Pittsburgh lost second consecutive game while leading after five innings.

"It's all about playing a complete game," Pirates manager Clint Hurdle said. "We weren't able to finish the last two games. We were in position to win them."

Samardzija won his second straight start, allowing two runs and six hits in six innings. John Jaso homered against Steven Okert in the eighth, and Sam Dyson pitched a perfect ninth for his second save this season.

"We're going out there and I don't think we're looking it as a whole right now," Samardzija said. "I think we're looking at it as a game-by-game moving forward. I just think we need to go out every day and set a tone with the way we start."

The pitching as a whole impressed Giants manager Bruce Bochy.

"What a great job they did this series," Bochy said. "Starters. Bullpen. Samardzija was really good. One mistake, a slider on the inside part of the plate there. He threw the ball well. He threw another great game. We deserved win for him."

On their longest winning streak since taking eight in a row from June 11-19 last year, the Giants have swept three-game series from Colorado and Pittsburgh after failing to sweep any series this season before that. San Francisco has won six straight at Pittsburgh for the first time since 1953.

Williams gave up two runs and three hits in six innings. He has five straight no decisions with four coming off of quality starts.

"The numbers, it is what is," Williams said. "At the end of the year they'll be where they're at. I feel like I've given the bullpen bad situations."

WEB GEM

Pence made a diving, tumbling backhand catch in right-center to rob John Jaso of an extra-base hit with two outs in the third. That stranded Jose Osuna, who had tripled off the right-field wall.

"What was impressive about Pence's catch was I think he was a little upset on the first ball he didn't catch there, the (Osuna) hit," Bochy said. "Then makes that diving catch there and saves us. We were determined to make the next play."

REST DAY

Pittsburgh did not start CF Andrew McCutchen, 2B Josh Harrison and 3B David Freese. Freese pinch hit in the seventh inning and Harrison in the ninth.

TRAINER'S ROOM

Pirates: OF Starling Marte went 0 for 3 and reached on a throwing error Sunday in a rehab assignment with Class A Bradenton. Serving an 80-game drug suspension, Marte is eligible to return to the Pirates on July 18, barring postponements. Pittsburgh manager Clint Hurdle said Marte will play left field when he returns.