Cain felt tightness in the second inning against the Colorado Rockies on Friday and exited the game soon after. He had an MRI on Saturday.
He is 1-5 with a 5.20 ERA this season.
The 31-year-old Cain suffered a similar injury in 2014 that led to a stint on the disabled list.
To take Cain's place on the roster, the Giants recalled right-hander Chris Stratton from Triple-A Sacramento. Stratton was in uniform Saturday.
Just before the game, the Giants scratched outfielder Denard Span from the starting lineup because of a sore right hip. Outfielder Hunter Pence (strained hamstring) and infielder Brandon Belt (sprained left ankle) were back in the lineup.