Robbie Ray pitched shutout ball into the seventh inning despite some control issues, Jake Lamb hit a bases-loaded triple and the Arizona Diamondbacks beat the San Francisco Giants 4-3 on Tuesday night.

Chris Iannetta added an RBI single, and A.J. Pollock singled, scored and made a stellar play in center field to rob Aaron Hill of extra bases in the third. The Diamondbacks won for the fourth time in six games against San Francisco.

Arizona improved to 7-2, matching its best start in franchise history.

Ray (1-0) settled in after pitching out of a pair of early jams and overcame matching his career high of five walks. The lefty struck out eight and allowed four hits over 6 2/3 innings.

Fernando Rodney struck out pinch-hitter Brandon Crawford with the tying run at second to end the game. Rodney allowed two runs but earned his third save.

Jeff Samardzija (0-2) allowed three runs in 6 2/3 innings.