SAN FRANCISCO -- Chad Gaudin shut out the Arizona Diamondbacks on three hits over seven innings and the San Francisco Giants got to nemesis Ian Kennedy for all the runs they would need in a two-run first inning en route to a 2-0 victory over the National League West division leaders.
Buster Posey and Hunter Pence drove in runs in the decisive first inning as the fourth-place Giants opened a 10-game homestand by beating Kennedy (3-7) for the first time in 11 starts to move within 5 1/2 games of the Diamondbacks in the NL West.
The defending division champs ran their record to 7-3 against the Diamondbacks this season. The two teams will meet nine more times in the season's second half, including six more times in San Francisco.
Gaudin (4-1), who joined the Giants' starting rotation after Ryan Vogelsong broke his right hand May 20, remained unbeaten as a starter with his fourth victory in seven starts.
He did it by once again dominating right-handed hitters, holding Arizona's four righty batters hitless in 11 at-bats. The 30-year-old entered the game having held right-handed hitters to just a .172 average.
Gaudin left for a pinch hitter after seven innings, having matched his season-high with 92 pitches. He didn't walk a batter and struck out eight.
All three hits off the right-hander were singles. The Diamondbacks never advanced a runner past first base against him.
Catcher Miguel Montero had two of the three hits off Gaudin.
Right-hander Santiago Casilla, the fourth Giants pitcher of the inning, got All-Star Paul Goldschmidt to ground to shortstop with two outs and the bases loaded in the eighth inning to preserve the 2-0 lead.
Closer Sergio Romo pitched a scoreless ninth inning for his 22nd save.
The loss was Arizona's 11th in its last 14 road games. It shrunk the Diamondbacks' lead over the second-place Los Angeles Dodgers to 1 1/2 games in the NL West.
Failing to record his 50th career win for an eighth consecutive start, Kennedy held the Giants scoreless after a three-hit, two-walk first inning. He pitched six innings, giving up just the two runs on five hits. He walked three and struck out three.
The Giants out-hit the Diamondbacks 8-5. Pence and Brandon Belt had two hits apiece for San Francisco.
All five Arizona hits were singles, snapping a string of 79 consecutive games with at least one extra-base hit. The streak had been the longest in the majors.
NOTES: Despite entering the game 6 1/2 games behind the Diamondbacks, the Giants (27-20) had a far better record against NL West competition than Arizona (21-22). ... The Giants began the second half having played the most road games (51) in the NL. They get 37 of 67 at home to finish the season. ... Giants manager Bruce Bochy announced before the game he expects Vogelsong, out since May 20 with a broken right (pitching) hand, back in the starting rotation shortly after Aug. 1 and CF Angel Pagan, who underwent hamstring surgery June 25, back atop the lineup on or around Sept. 1. ... When the Diamondbacks return home Monday to open a four-game series against the Chicago Cubs, they'll be greeted by the "Luchador," a professional wrestler look-alike who Thursday was named the club's official mascot. The first 20,000 fans at the team's July 27 game against the San Diego Padres will receive Luchador masks.