DENVER (AP) -- Matt Cain pitched the San Francisco Giants into first place - and nearly did it with a no-hitter.
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."
Cain (13-10) retired his first 12 batters before making a throwing error on Troy Tulowitzki 's bouncer to start the fifth. Cain also walked Ryan Spilborghs in the inning, but struck out three.
"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."
Freddy Sanchez gave Cain an early lead. After Jorge De La Rosa (8-6) began the game by walking Cody Ross on four pitches, Sanchez homered to left on De La Rosa's 0-2 pitch.
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.
The Giants added a run in third after Aubrey Huff led off with a double and advanced to third when the Rockies botched a rundown. Pat Burrell followed with a sacrifice fly.
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."
Notes: 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.