Matt Cain, strained hamstring? Buster Posey, irritated back?

Not even injuries can slow the roaring Giants, the first big-league team with 40 wins. No. 40 was Friday night's come-from-behind 4-2 victory over the Mets, which put the Giants a month ahead of last year's pace. They won their 40th in 2013 on July 6.

In Cain's first start since May 21, the day he limped off the field in Denver with a bum hamstring, he retired his first 12 batters and didn't surrender a hit until the sixth inning. Posey, who has slumped at home and missed time lately with his back issue, collected three hits, including a decisive two-run homer in the eighth inning.

"This team is very impressive with its willingness to fight," said closer Sergio Romo, whose perfect ninth inning sealed the Giants' 11th win in 14 games. On his 35th birthday, Jeremy Affeldt, who pitched the eighth, earned the win.

When Posey wasn't catching Cain's quick innings, he was at the plate getting his China Basin groove back. He entered a .196 hitter at home, a far cry from his .326 road average, and singled off lefty Jonathon Niese in his first two at-bats.

In the eighth, he faced righty Carlos Torres with one out and Angel Pagan on second base, and cleared the left-field wall for his first homer since May 3 in Atlanta and first at home since April 29.

Asked to explain why he had been such a better hitter away from home, Posey said, "Baseball's weird."

Cain, with his 2012 perfect game fresh in fans' memories, needed 13 pitches in the first inning, 10 in the second, 11 in the third and nine in the fourth. His teammates weren't breaking a sweat. When Curtis Granderson, leading off the fifth, took a 3-1 pitch that was ruled a ball but could have been called a strike, the Mets had their first runner.

No worries. Andrew Brown promptly bounced into a double play.

The next inning, Ruben Tejada opened with the Mets' first hit, a slow roller to the right of shortstop Brandon Crawford, who had no play.

Again, no worries. It was Travis d'Arnaud's turn to hit into a double play, and Cain had faced the minimum through six innings.