Conor Jackson singled with two outs and stole second to set up Dunn's game-winning hit as the Diamondbacks swept four games from the Giants to stay 3 1/2 games behind the first-place Los Angeles Dodgers in the NL West with 10 to play. The Dodgers won at Pittsburgh 4-3 in 12 innings on Thursday.
Lincecum (17-4) was 6-0 in 10 starts since losing to Milwaukee 7-4 on July 20. He allowed three runs and six hits in his second straight complete game and second of his career. The 24-year-old right-hander struck out six and hit a batter in his first loss in his six appearances against Arizona.
The Diamondbacks blew a lead for Randy Johnson for the fifth time this season, again depriving the 44-year-old left-hander of his 295th career victory.
Johnson gave up a run in the first and scattered eight hits through seven innings, striking out four and walking one. He left with a 2-1 lead, but Bengie Molina homered on his first pitch from reliever Juan Cruz (3-0) in the eighth to tie it.
Chad Qualls threw a perfect ninth for his fifth save in 13 tries.
Eugenia Velez misjudged Justin Upton's line shot to left for a two-run triple with two outs in the sixth to give Arizona a 2-1 lead. Velez took a couple of steps in then saw the ball sail over his head. Stephen Drew started the rally with a double, then took third on Augie Ojeda's sacrifice bunt. Jackson was hit by a pitch, then Dunn struck out to bring Upton to the plate.
Upton's hit ended Lincecum's string of 14 scoreless innings. He was coming off the first complete game shutout of his career, a 7-0 victory at San Diego.
Lincecum went down in pain when he was hit in his left hand attempting to bunt in the fifth inning. Johnson's pitch was inside and high and it hit the hand where Lincecum was holding the bat.
The San Francisco ace eventually got to his feet and was back on the mound when the Giants took the field.
The Giants loaded the bases with no outs in the first but managed only one run. Randy Winn and Ivan Ochoa opened the game with singles, then Rich Aurilia walked. Winn scored on Pablo Sandoval's one-out sacrifice fly.
Notes:@ Seven Giants singled off Johnson. ... San Francisco plays six of its remaining nine games against the Dodgers. ... Arizona manager Bob Melvin gave 3B Mark Reynolds the night off. Reynolds has taken over the NL lead in strikeouts with 191, one more than Philadelphia's Ryan Howard. ... Arizona last won four straight from July 29-Aug. 1.