Updated

The San Francisco Giants' offense broke out and helped snap a six-game losing streak in a 5-2 win against the Colorado Rockies in the finale of a three-game series.

Buster Posey and Hunter Pence each homered as the Giants also won for the first time in their last eight road games.

"I think getting the win was good. Obviously that's what we're here for, we're here to win," Pence said. "Our pitching's been really picking it up for us and we found a way to get it done."

Madison Bumgarner (8-5) tossed his fourth straight quality start to earn the win. Bumgarner gave up one run on four hits with five strikeouts over seven innings.

Carlos Gonzalez launched his 22nd home run of the season for the Rockies, who lost for the fourth time in six games.

Michael Cuddyer went 1-for-4 to extend his hitting streak to 27 games.

"It's fun. I've never been doing anything like this before," Cuddyer said of his hit streak. "You just enjoy the ride."

Drew Pomeranz (0-1) surrendered four runs on seven hits with four walks to take the loss in his 2013 major league debut.

The Giants had led in just two of their previous 54 innings coming into Sunday, but they took the lead in the third and never gave it up. Posey provided the visitors with an early edge when he blasted a fastball deep into the left-field seats with one out in the third.

San Francisco tacked on three more runs in the fifth inning. Andres Torres led off with a single and moved to third on Tony Abreu's double. Posey grounded out to second and failed to score Torres off the bat, but Rockies first baseman Jordan Pacheco tried to catch Abreu off second base and threw the ball into left field. The error plated Torres, but it did not matter after Pence followed with a home run to right-center field, opening up a 4-0 lead.

Gonzalez lined a first-pitch breaking ball out to right-center field to put Colorado on the board in the sixth.

The Giants scored again in the seventh inning. Juan Perez drew a two-out walk and hustled home all the way from first when Guillermo Quiroz's pop up fell into right field for a base hit.

Cuddyer grounded a base hit off the thumb of Giants pitcher Sandy Rosario and into center field, extending his hitting streak to 27 games and his on-base streak to 46 games. Cuddyer scored when Wilin Rosario followed with a double.

Sergio Romo worked around a two-out double in the ninth for his 19th save.

Game Notes

The Giants are 39-42 through 81 games, the halfway point of the season ... Posey has reached base in 48 straight games against the Rockies. In that span, he owns a .411 average (72-for-175) ... The Giants finish June 10-17 ... San Francisco had scored 18 runs in its previous nine games coming into Sunday ... Bumgarner is 3-1 with a 1.61 earned run average (five earned runs in 28 innings) in his last four starts ... Cuddyer is hitting .372 during his hitting streak (42-for-113), which dates back to May 28.