Pablo Sandoval opened the 10th inning with a pinch-hit homer after shortstop Brandon Crawford made a game-saving stop in the ninth, helping the San Francisco Giants beat the Arizona Diamondbacks 3-2 on Sunday.

The Diamondbacks appeared to have the game won when Adam Jones hit a grounder into the hole off Sam Dyson (2-0) with a runner on third with two outs in the ninth.

Crawford made a spectacular play to save the Giants, diving to his right and hopping up to make a throw that beat Jones by a step.

Arizona Diamondbacks shortstop Nick Ahmed backhands a ground ball hit by San Francisco Giants' Drew Pomeranz during the second inning of a baseball game, Sunday, May 19, 2019, in Phoenix. (AP PhotoRalph Freso)

Arizona Diamondbacks shortstop Nick Ahmed backhands a ground ball hit by San Francisco Giants' Drew Pomeranz during the second inning of a baseball game, Sunday, May 19, 2019, in Phoenix. (AP PhotoRalph Freso)

Sandoval had a pinch-hit homer in the eighth inning of San Francisco's 8-5 win Saturday night and added another to left field off Yoshihisa Hirano (1-2). Sandoval has 40 RBIs at Chase Field, his most in any opposing ballpark.

Will Smith struck out the side in the ninth for his 11th save in 11 opportunities.

The Giants scored two runs off Robbie Ray in the third, but went 20 straight at-bats without a baserunner until Mac Williamson walked with two outs in the ninth. Sandoval's hit was San Francisco's first since Donovan Solano's single with no outs in the third.

Arizona Diamondbacks starting pitcher Robbie Ray throws against the San Francisco Giants during the first inning of a baseball game, Sunday, May 19, 2019, in Phoenix. (AP PhotoRalph Freso)

Arizona Diamondbacks starting pitcher Robbie Ray throws against the San Francisco Giants during the first inning of a baseball game, Sunday, May 19, 2019, in Phoenix. (AP PhotoRalph Freso)

The Diamondbacks finished with three hits.

Ray had been on a roll, entering 3-0 with a 1.98 ERA and 35 strikeouts in 35 1/3 innings. He had command issues against the Giants, needing 29 pitches just to strand runners at second and third in the first inning.

Ray walked in a run in the third inning and another came across on Kevin Pillar's groundout.

San Francisco Giants' Kevin Pillar makes contact on an inside pitch by Arizona Diamondbacks pitcher Robbie Ray during the first inning of a baseball game, Sunday, May 19, 2019, in Phoenix. (AP PhotoRalph Freso)

San Francisco Giants' Kevin Pillar makes contact on an inside pitch by Arizona Diamondbacks pitcher Robbie Ray during the first inning of a baseball game, Sunday, May 19, 2019, in Phoenix. (AP PhotoRalph Freso)

Ray allowed two runs on three hits and walked four in four innings. He struck out six.

San Francisco's Drew Pomeranz was reinstated from the 10-day injured list prior to the game after missing nine games with a left arm strain.

He had some control issues of his own — two walks and a hit batter in the second inning — but didn't give up a hit until David Peralta's leadoff infield single in the fourth.

Nick Ahmed followed with a run-scoring double and Christian Walker scored from third on a pitch that caromed off home plate umpire Joe West's mask.

Pomeranz allowed two runs on two hits and walked five in 4 2/3 innings.

TRAINER'S ROOM

Diamondbacks: 2B Wilmer Flores left in the fourth inning after getting hit on the right foot by a pitch in the third. Ketel Marte moved from center field to second base and Jarrod Dyson entered in center. He missed Saturday's game with a left hand injury after being hit while attempting to bunt the day before. ... Peralta went 2 for 3 after being held out of Saturday's game with upper back pain.

UP NEXT

Giants: LHP Andrew Suarez will be recalled from Triple-A Sacramento to start Monday against Atlanta. He went 7-13 with a 4.49 ERA in 29 starts for the Giants last season, but did not make the rotation coming out of spring training this year.

Diamondbacks: RHP Luke Weaver is 3-0 with a 0.98 ERA in his past three road starts heading into Monday's game against San Diego.

More AP MLB: https://apnews.com/MLB and https://twitter.com/AP_Sports