Updated

A day after having his perfect game commemorated, Matt Cain shook off his recent struggles and helped the Giants snap out of a home funk.

Cain tossed 7 1/3 innings of two-run ball and visited the win column for the first time in nearly a month as San Francisco downed the Colorado Rockies, 9-3, in the middle test of a three-game set.

Cain (11-5), who had been 2-3 with a 4.40 ERA coming in since his perfect game, fanned six, scattered seven hits and walked one. It was his first win since defeating the Houston Astros on July 15.

"This was the Matt Cain we know," Giants manager Bruce Bochy said.

Buster Posey smacked two hits, including a two-run homer, and Angel Pagan had a two-run triple for Giants, who won for just the second time at home in their last 10 attempts.

"We're going to have to pick it up here at home," Bochy said.

Drew Pomeranz (1-7) allowed four runs on six hits with four strikeouts over four frames for Colorado, which had won three of its last four.

"I just made some bad pitches and they put some good swings on my bad pitches," Pomeranz said.

The Giants jumped out to a quick five-run lead after plating a pair in the second and third innings and then adding another run in the fifth.

Three of San Francisco's first four batters in the second, Posey, Brett Pill and Ryan Theriot, singled to load the bases with one out. Joaquin Arias brought Hunter Pence, who reached on a fielder's choice, home with a sacrifice fly and Cain's base hit to center scored Pill to give the Giants a 2-0 advantage.

In the third, Melky Cabrera reached with a one-out bunt single and Posey hammered a two-run homer into the front row of seats in left-center, extending the margin to 4-0.

Pence ripped an opposite-field, RBI double in the fifth, but the Rockies finally got on the scoreboard in the sixth on Josh Rutledge's RBI groundout, making it a 5-1 game.

Pagan laced a two-run triple into the gap in right-center and Marco Scutaro lined a run-scoring base hit to left in a three-run home sixth, pushing the edge to 8-1.

DJ LeMahieu registered his first career long ball with a leadoff shot in the visitor's eighth, but Arias whacked a triple off the bricks in right-center and later scored on a wild pitch to make it 9-2 in the home half.

Chris Nelson's RBI single in the ninth concluded the scoring.

Game Notes

Cain improved to 4-0 over his past five starts against the Rockies...Posey's homer was his 19th of the season...The Giants were 5-for-10 with runners in scoring position, while Colorado finished 2-for-9.