PHOENIX -- The more Giants who step forward to excel for the team, the better off they'll be as this season approaches what could be an exciting conclusion. Matt Duffy added his name to the list of key performers Wednesday.

Duffy's two-run pinch-hit single broke a ninth-inning tie and lifted the Giants to a 4-2 victory over the Arizona Diamondbacks. The decision trimmed the Giants' deficit in the National League West standings to two games, coupled with the 16-2 shellacking first-place Los Angeles absorbed at Colorado.

The Giants struggled with their collaborative efforts for most of the afternoon at Chase Field. Madison Bumgarner registered one perfect inning among the six he worked.

"I felt like there were runners in scoring position the entire time," the left-hander said. Meanwhile, San Francisco mustered three hits in six innings against D-backs left-hander Andrew Chafin, who made his second Major League start.

The Giants were locked in a 2-2 tie with Arizona when Pablo Sandoval began their ninth-inning uprising by drawing a walk from D-backs reliever Addison Reed (1-6). Brandon Crawford, who went 4-for-4, lined a one-out single to accelerate the rally. Belt, who hadn't played since Aug. 6 due to concussion symptoms, pinch-hit for Juan Perez and walked on a 3-2 pitch to load the bases.

Up came Duffy, who rapped another full-count pitch to center field, delivering Sandoval and Crawford.

"If he doesn't get that hit right there, who knows what happens," Crawford said. "He laid off some really tough pitches."

The 23-year-old rookie improved to 4-for-10 as a pinch-hitter, a role that's typically more suitable for veterans or ex-regulars who possess experience, as well as a sweet swing. But Duffy owns the latter trait, and his hitting aptitude helps him compensate for his lack of the former attribute.

The positive attitude that Duffy derives from being called upon by Bochy also helps.

"When he shows confidence in you, it gives you confidence in yourself," Duffy said.

As the count inched to 3-2, Duffy employed common sense as he tried to think along with Reed. "I knew he had to come in with a strike," he said.

Crawford, who rose from Class A Advanced San Jose to the Majors in 2011, can relate to the challenges facing Duffy. "The game can really speed up on you," Crawford said. "You really just try to keep it simple and remember it's the same game."

With 21 hits in his last 49 at-bats (.429) and 13 RBIs in his last 15 games, Crawford has been following his own advice. Aside from him and Duffy, the only other Giants player to hit safely on Wednesday was Bumgarner, who lined a third-inning single.

But once the Giants forged ahead, they were safe. Sergio Romo (6-4) pitched a scoreless eighth to earn the decision before Santiago Casilla recorded his 17th save and second in two days. Bochy took this opportunity to praise Romo for making the transition from closer to setup specialist.

Duffy was asked to dress in a faux cowboy outfit that was colored largely in pink, despite his feats on the field. This happened to be the day when rookies don garish costumes for the team's flight to the next city. No exceptions.

Grateful to be in the Majors, Duffy didn't care.

"They can dress me any way they want," Duffy said.

Chris Haft is a reporter for MLB.com. Read his blog, Haft-Baked Ideas, and follow him on Twitter at @sfgiantsbeat. This story was not subject to the approval of Major League Baseball or its clubs.