SAN FRANCISCO -- Justifiably amped up for this one, Ian Kennedy took a couple of innings to find his command and his composure.
Once settled and in control, the National League's wins leader stole the momentum right back for first-place Arizona.
A night after not a lot went right for the D-backs in seeing their nine-game winning streak snapped, they bounced back and kept the pressure on the reigning World Series champion Giants.
"We won two out of three here last time," Kennedy said. "Winning at anybody's place you get confidence. You don't want to think negatively not to get swept. Every series you want to win. Coming into their yard, it's going to be tough playing them."
Aaron Hill and Gerardo Parra each hit RBI doubles as Arizona extended its division lead again to six games after losing the series opener 6-2. San Francisco figures it must win Sunday's series finale to keep alive any chance of defending the division crown and returning to the playoffs.
Kennedy (18-4) became the NL's first 18-game winner and has victories in his last three starts. He allowed one run on five hits in seven innings, struck out six and walked two.
"Whenever I hear 18 wins, I think of a good bullpen and a good offensive team, timely hitting, really," Kennedy said.
The Giants managed only a pair of sacrifice flies by Pablo Sandoval to back Lincecum (12-12).
What had been billed as a marquee pitching matchup of staff aces looked to be just that in the early innings.
Then Arizona's hitters began to find a groove against Lincecum, the two-time NL Cy Young winner handed his career-high 12th loss. The ace has lost his last two starts -- with an 11.33 ERA over those two outings -- and two of three.
"He just made some mistakes," manager Bruce Bochy said. "I thought he came out with good stuff and lost his command. They took advantage of it and kept chipping away at him. I think long innings were catching up with him. ... We just couldn't get a big hit to do some damage there. They got them and we didn't."
Hill's second double of the game in the third made it 1-0. The ball died coming off the wall in left rather than rebounding and it fooled Pat Burrell, who later came out of the game with soreness in his troublesome right foot that caused him to miss 43 games on the disabled list. It's something Burrell has said he will deal with this month while he tries to play through the pain.
San Francisco answered in the bottom half of the third on Sandoval's first sacrifice fly.
Goldschmidt connected for his sixth home run in the fourth to put the D-backs ahead for good, then hit an RBI single in the fifth.
"His pitch count kind of got up," Goldschmidt said. "He's so good, you just have to try to capitalize on any mistakes you get, and if he falls behind try to make it hurt."
Montero later extended his career-best hitting streak to 12 games with a base hit in the ninth.
Carlos Beltran followed up a four-hit game a night earlier -- in which he hit a two-run homer and an RBI single -- with three more, including a double. He also drew a walk, giving him eight straight plate appearances reaching base safely.
Beltran is 17 for 31 (.548) against Arizona this season.
Still, the banged-up Giants failed to string together their first three-game winning streak since July 17-19 at San Diego. They will try Sunday for their first winning home series in seven sets since taking two of three from Milwaukee from July 22-24.
They haven't won a series at all in their last five since taking two of three at Florida from Aug. 12-14.
So, Sunday is a must-win with 23 games to go.
Arizona beat Lincecum at sold-out AT&T Park for the second time in just over a month after a win against the Freak here on Aug. 2.
"Of course, this is disappointing," Lincecum said. "Obviously these two games are big for us ... and them throwing something like that isn't good for anybody. Tomorrow we have to come and get them."
Lincecum allowed nine hits and five runs and struck out seven in five innings, his shortest start since also going five against San Diego on July 4.
He reached 200 strikeouts for the fourth straight year, joining Amos Rusie (1890-93) in New York and Hall of Famer Juan Marichal (1963-66) in San Francisco as the only Giants to do so in four consecutive seasons.
But six of his nine hits allowed went for extra bases.
"We got him in some situations and got some key hits," D-backs manager Kirk Gibson said. "The team responded well to last night."
Aubrey Huff's second-inning single was his 10th hit in 25 at-bats vs. Kennedy. ... Injured Giants pitchers Barry Zito (right foot/ankle) and Brian Wilson (elbow inflammation) both threw -- Zito off the mound and Wilson on flat ground. ... Unlikely All-Star Ryan Vogelsong (10-5) pitches the series finale for the Giants on Sunday trying to end a three-start skid. Daniel Hudson (14-9) takes the mound for the D-backs looking to win his third straight outing. ... The mother of severely beaten Giants fan Bryan Stow threw out the ceremonial first pitch. Ann Stow was accompanied by family members of the Santa Cruz paramedic, who was beaten outside Dodger Stadium on opening day March 31. The family received a standing ovation on "Strike Out Violence Night." Home run king Barry Bonds, who has donated money to the college fund for Stow's two young children, was at the game in support and sitting with the family. ... SS Joe Panik, San Francisco's top draft pick this year, and OF prospect Gary Brown have received two of the club's five spots for the Arizona Fall League -- joining September callup Brandon Crawford.