Colorado missed out on a chance for what would have been its first road series sweep of the season.
Cain (4-4) gave up a fourth-inning homer to Troy Tulowitzki but then shut the door on the Rockies and went eight innings. Wilson needed only eight pitches in a perfect ninth for his 13th save.
Rowand's double in the fifth gave San Francisco a 2-1 lead. The Giants added two more in the sixth -- Pablo Sandoval driving in a run with a double and Bengie Molina adding an RBI single.
Jeff Francis (1-2) gave up four runs on eight hits in 5 2/3 innings to take the loss.