DENVER (AP) -- Madison Bumgarner gave the San Francisco Giants a much-needed lift.
Bumgarner scattered four hits over seven innings, Hunter Pence hit a two-run homer and the Giants ended their longest losing streak in three years with a 5-2 victory over the Colorado Rockies on Sunday.
''It was a big win for us,'' Bumgarner said. ''I feel like that you have to think you have to be there every time out really, whether you're winning or losing.''
San Francisco had lost six straight, its longest skid since dropping seven in a row from June 26-July 1, 2010. The World Series champions had dropped seven straight road games.
''Bumgarner has been consistent all year,'' San Francisco manager Bruce Bochy said. ''He's been consistent in every start. He's a special talent. and he showed that today.''
Bumgarner (8-5) struck out five and walked three, improving to 4-1 with a 2.18 ERA in his last five starts. Sergio Romo pitched a one-hit ninth for his 19th save in 21 chances.
Colorado was impressed with his offspeed pitches.
''He kept us off guard with his command of that pitch throughout the game,'' Colorado manager Walt Weiss said. ''It is what you expect from on the better pitchers in the league.''
Colorado's Michael Cuddyer singled in the eighth off Sandy Rosario, extending his hitting streak to 27 games. The streak is the longest in Rockies history and in the majors this season. He has reached base safely in a franchise-record 45 straight games.
''I got a slider for the hit, and got it just under the glove of the shortstop,'' Cuddyer said.
Drew Pomeranz (0-1), making his 2013 big league debut after being recalled from Triple A Colorado Springs, allowed four runs, seven hits and four walks in 4 1-3 innings.
Buster Posey put the Giants ahead with a solo homer in the third.
San Francisco extended its lead to 4-0 in the fifth on a run-scoring throwing error by first baseman Jordan Pacheco on Posey's grounder and Pence's 13th homer.
Carlos Gonzalez hit his 22nd homer of the season in the sixth.
NOTES: The Giants avoided what would have been their fifth series sweep. ... San Francisco RHP Chad Gaudin (bruised right elbow) threw a bullpen session Saturday, and Bochy said he will be ready to be activated from the DL when he is eligible on July 6. ... 3B Nolan Arenado was limping after being hit in the left ankle by Bumgarner in the sixth but remained in the game. ... Dexter Fowler missed his fifth straight game with a sore right hand. Weiss said Fowler showed improvement and could be ready Tuesday.