SAN FRANCISCO -- Matt Cain didn't have to be perfect to slow down the mighty Mets. His defense sure did.
Cain stymied the Mets and singled in a run to help his cause, and the San Francisco Giants ended an eight-game losing streak to New York with a 2-0 victory Sunday night.
"That group swings it," Cain said of New York's powerful batting order. "And they're definitely hot right now."
Bengie Molina also had an RBI single as San Francisco snapped a four-game skid and avoided a four-game home sweep in a game that featured a rare three balks by Mets starter Mike Pelfrey. The Mets didn't dispute those calls afterward.
New York's potent offense couldn't get to Cain after producing 24 runs, 42 hits and 13 stolen bases in the first three games of the series. The Mets, in the midst of a 10-game road trip, lost for only the fourth time in 16 May games.
Pelfrey (4-1) kicked the mound in frustration following his third balk, in the sixth, that drew pitching coach Dan Warthen out for a visit.
"I think maybe when I get on national TV I like making a fool of myself," Pelfrey said. "It seemed like I almost had the yips. It was like I was fighting myself to come set because my mind kept telling me to pick the guy off. I went back and watched replays and I balked."
The last pitcher to have three balks in a game was Al Leiter for Toronto against Minnesota on April 23, 1994. It was only the second time in Mets franchise history that a pitcher had three balks. Don Rowe did it on April 27, 1963, at Philadelphia.
Bob Shaw holds the NL record with five balks for the Milwaukee Braves against the Cubs on May 4, 1963 -- and he had three in one inning.
Carlos Beltran's double in the eighth against Jeremy Affeldt put runners on second and third with no outs and gave him an 11-game hitting streak, but pinch-hitter Angel Pagan grounded into an inning-ending double play with the bases loaded.
Cain (4-1) pitched six shutout innings, and Bob Howry, Affeldt and Brian Wilson finished the five-hit shutout. Wilson earned his ninth save in 11 opportunities after losing the first two games of the series to New York.
Cain had lost last three outings to the Mets dating to a win during his rookie season of 2006. The right-hander also pitched six shutout innings in his last win, May 7 at Colorado.
"He did everything today," first baseman Travis Ishikawa said. "No. 1 was his pitching and keeping us in the game."
Pelfrey walked Cain to start the third for the Mets' first free pass in three games, then allowed a single to the pitcher in the fifth that put the Giants ahead 2-0. New York had come from behind to win both Thursday and Friday nights, then broke open a tie game Saturday to win 9-6.
Cain escaped a bases-loaded jam in the second after three straight walks when the Giants turned a 3-2-3 double play on Jeremy Reed's hard grounder to Ishikawa, who pumped his fist to celebrate.
"They had a lot of fight in them today," Mets manager Jerry Manuel said. "Even their fans seemed to be in a playoff-type atmosphere. They didn't want the Mets to do the sweep here."
Mets shortstop Alex Cora left the game with a sprained right thumb after sliding into second base on his first-inning double. He was to be re-evaluated Monday. Fernando Tatis replaced him for his fourth career game at shortstop and first since Sept. 13, 1998, at Houston while with the Cardinals.
The Mets have sent some fans a survey, according to metspolice.com, asking whether the team should keep black uniform jerseys, whether they should wear white and pinstripes more often at home, whether fans would like white jerseys with an interlocking "NY" or blue jerseys with an interlocking "NY," among other questions. Fans also were asked for their opinions on caps and what the bridge at Citi Field should be named. ... Fans lined up hours before the game to be among the first 10,000 in the gates and receive a bobblehead doll of NL Cy Young Award winner Tim Lincecum. ... The Giants improved to 15-0 when they score first.