Cain held the fading Colorado Rockies hitless into the eighth inning and finished the game himself, leading the Giants to a 4-2 victory Sunday that put them atop the NL West again.
San Francisco moved a half-game ahead of San Diego, which lost to Cincinnati 12-2. The Rockies, who have dropped six of seven, fell 4 1/2 games behind the Giants and four back of the Padres in the wild-card race.
Cain was working on a no-hitter until speedy Jay Payton legged out an infield single with one out in the eighth. Giants shortstop Juan Uribe shuffled in and to his left to field Payton's slowly hit grounder but had trouble making the exchange, and the 37-year-old Payton beat the throw to first.
"I missed the ball a little bit," Uribe said. "The guy is throwing a good game. I want to make a play."
Cain struck out Miguel Olivo, but pinch-hitter Melvin Mora homered to cut San Francisco's lead in half. The two-run shot ended Cain's scoreless streak at 20 innings and his chance for a third career one-hitter.
Still, the right-hander went the distance on a three-hitter for his 12th career complete game and fourth this season. He won his fourth straight start and hasn't lost in seven outings since Aug. 18.
It was the fifth time in his career that Cain has carried a no-hitter into the seventh.
"This was probably the best opportunity to do it with a reasonable pitch count," said Cain, who threw 113 pitches. "I felt like I had good enough stuff and felt like I had enough oomph at the end to be able to throw down in the zone and still be able to throw my pitches the way I wanted to."
"What a great effort," Giants manager Bruce Bochy said. "To get a game like that in this park, you don't see it very often. It shows you how strong he is, not just physically."
San Francisco's stingy pitching staff got back on track after a 10-9 loss in 10 innings Saturday night. That ended a stretch of 18 consecutive games in which the Giants didn't allow more than three runs, the longest streak in the majors since the Chicago White Sox set the record with 20 straight in 1917, according to the Elias Sports Bureau.
Cain has allowed three hits or fewer in his past three starts.
"I felt good, but they were helping me out some swinging at early pitches," Cain said. "I just tried to focus on getting ahead and throwing strikes in the bottom of the zone to let some of my off-speed stuff work later on in the game."
San Francisco took two of three in the series at Coors Field, where the Rockies are 52-26.
"This is as tough a place to win as any place in baseball," Bochy said. "We knew we needed to do it with our situation, and the guys got it done."
Sanchez strained his right shoulder turning a double play in the sixth inning Saturday night and came out in the eighth. Bochy said he wanted to be sure Sanchez's shoulder felt fine during batting practice before putting him in the lineup.
There was no problem, and Sanchez hit his seventh homer of the season, lofting a fastball from De La Rosa down the left-field line. De La Rosa has allowed at least one homer in five consecutive starts.
De La Rosa allowed four hits, five walks and three runs in six innings. Matt Reynolds gave up a homer to Ross with one out in the seventh.
After making a late run at the division lead, the Rockies have lost three of their past four series.
"To lose two out of three in a big series is tough. But at the same time, anything can happen. We're still in it," Tulowitzki said. "Atlanta and San Diego lost -- that opens up the door a little bit. But at the same time, our chances every single day are getting a little slimmer."
Olivo left in the ninth when shortstop Tulowitzki came running across the diamond to catch Cain's popup between the mound and first base and clipped Olivo in the head or neck with his right leg. ... Flulike symptoms kept Rockies third baseman Ian Stewart from making his first start since Aug. 25. He has played in two games since returning Sept. 23 from a right oblique strain. ... Giants outfielder Andres Torres was not in the lineup. He made his first start Saturday since returning from an appendectomy Sept. 11 and homered but experienced irritation around the incision later in the game. ... Rockies 2B Eric Young Jr. was in the lineup after leaving with a bruised neck in the second inning Saturday night. ... Cain pitched one-hitters on May 21, 2006, at Oakland, and May 28 this season against Arizona.