PHOENIX (AP) -- Pinch-hitter Matt Duffy delivered a tiebreaking single in the ninth inning and the San Francisco Giants narrowed their gap in the NL West, beating the Arizona Diamondbacks 4-2 Thursday.
The Giants pulled within two games of the division-leading Los Angeles Dodgers, who lost at Colorado 16-2. The contenders each have 10 games left.
Duffy's one-out hit came on a full count against closer Addison Reed (1-6). Pablo Sandoval walked with one out, Brandon Crawford singled and pinch-hitter Brandon Belt walked, setting up Duffy. Crawford had four hits.
Sergio Romo (6-4) pitched one inning, and Duffy batted for him. Santiago Casilla got his 17th save.
Crawford hit an RBI double in the second for a 1-0 lead.
Andrew Chafin, making just his second major league start, tied it in the Arizona second with an RBI single off Madison Bumgarner. The hit came in Chafin's first big league at-bat.
Bumgarner labored through six innings allowing at least two baserunners in the first three. Trying for his 19th win, he gave up seven hits and struck out six.
The Giants took the lead in the fifth thanks to an infield hit, a walk, a wild pitch and a pair of sacrifices that produced one run.
Bumgarner gave up the tying run in the bottom of the fifth, when A.J. Pollock ran home on a thrown third strike that bounced to Giants catcher Andrew Susac. Susac threw out Mark Trumbo at first base, but Pollock hustled to the plate on the throw and beat Buster Posey's throw back to Susac.
Chafin allowed two runs on three hits with four walks and two strikeouts in six innings.
Giants: OF Angel Pagan was scheduled for an MRI on Wednesday for his back injury, and missed his third straight game. ... Belt played for the first time since being activated from a concussion on Monday.
Diamondbacks: 3B Jake Lamb (quad) remains limited, but is expected to return to the lineup when the team plays at Colorado beginning Thursday. Lamb came on as a pinch hitter on Tuesday and struck out.
Giants: RHP Tim Hudson (9-11) goes for the Giants on Friday at San Diego after the club gets Thursday off. He's coming off the worst start of his career, in which he allowed six runs on eight hits in one inning of a 17-0 loss to the Dodgers last week.
Diamondbacks: LHP Vidal Nuno (0-6) faces the Rockies in the opener of a four-game series Thursday. Nuno has a 2.31 ERA over his last five starts. He allowed one earned run in eight innings against the Rockies on Aug. 30 but took the loss.