SAN FRANCISCO—Right-hander Matt Cain left his start against the Pittsburgh Pirates in the top of the fourth inning Thursday night after getting hit in the pitching arm on a line drive by Pittsburgh's Gaby Sanchez.

The Giants said he suffered a contusion on right forearm and X-rays were negative.

Athletic trainer Dave Groeschner and manager Bruce Bochy hustled out to check on Cain, who walked off the mound to the dugout on his own moments later Thursday night. He allowed three runs and seven hits in 3 1-3 innings, struck out three and didn't walk a batter. Guillermo Moscosco relieved with the Giants trailing 3-1.

Cain, who had been on a nice roll since the All-Star break, threw 64 pitches, 40 strikes.