Cole Hamels pitched a complete game gem to carry the Philadelphia Phillies to a 2-1 victory over the slumping San Francisco Giants on Saturday for their ninth straight win.

Hamels scattered seven hits against the World Series champions while striking out five, and twice pitched himself out of danger for his 13th victory of the season for the National League East leaders.

"We had more hits than they did, we just couldn't get the big hit," Giants manager Bruce Bochy told reporters after their eighth loss in nine games.

"You don't win the World Series unless you can beat good pitching. Right now we're not doing that."

Philadelphia (74-39) scored two runs in the first inning, one unearned, against San Francisco starter Matt Cain, who then settled himself to complete eight solid innings.

"We got to him early but after that he was tough," said Phillies first baseman Ryan Howard.

"He (Cain) got into some situations where it could have gone bad, and Cole got into some situations where it could have gone bad, but they got out of them."

Cain allowed just two base runners after the first inning and at one point retired 11 consecutive batters.

But for all Cain's good work, the Giants (62-52) again struggled to get runs on the board.

In the fourth inning, San Francisco had a runner at second base with nobody out but Hamels managed to wriggle his way out of trouble in four pitches after striking out Carlos Beltran in three and forcing Pablo Sandoval to hit into a double play.

The Giants again had a runner at second base in the eighth but Aaron Rowand popped out to second baseman Chase Utley to end the inning.

But just as Hamels was on the verge of a shutout, Sandoval hit a solo home run at the bottom of the ninth for the Giants.

"I was just a little frustrated," Hamels said of missing out on the shutout.