PHOENIX (AP) — Pinch-hitter Pavin Smith connected for a two-run homer in the bottom of the ninth inning to lift the Arizona Diamondbacks over the San Francisco Giants 4-2 on Monday night.

Jake McCarthy got the winning rally started with a looping, one-out double down the left-field line. Smith — hitting for Eugenio Suárez — smashed a pitch from Randy Rodríguez (1-1) that barely cleared the yellow line above the wall in center.

“It’s pretty crazy, the stuff you sort of dream about,” Smith said. “You play it in your mind almost every day.”

The Diamondbacks have won three straight, while the Giants have dropped a season-high five in a row.

Lourdes Gurriel Jr. gave the D-backs a 1-0 lead in the second with a homer off Spencer Howard, which marked the 100th longball of his career. Blaze Alexander’s RBI single up the middle later in the inning scored Suárez — who reached on a triple off the wall in right-center — for a 2-0 advantage.

San Francisco’s Matt Chapman hit a double in the fourth that drove in Brett Wisely, cutting it to 2-1. Heliot Ramos tied it at 2 in the seventh with a solo shot to the deepest part of the park in right-center.

The Giants threatened in the ninth, putting runners on first and third with two outs. Jorge Soler hit a bouncing ball down the third base line to Suárez, who fired high to first, but Christian Walker was able to leap into the air and grab the throw before tagging Soler just before he crossed the base.

“It’s a game of inches, right?” Giants manager Bob Melvin said.

The stellar defensive play by Walker set the stage for Smith, who hit just his second homer of the season and his first career walk-off.

Diamondbacks right-hander Ryne Nelson gave up two runs over 7 2/3 innings, the longest outing of his career. He yielded six hits and struck out one.

Nelson came into the game with a 6.02 ERA but coaxed lots of early contact from the Giants, needing just 80 pitches to navigate through his outing.

“The fastball command and the slider really showed up tonight,” Nelson said. “And the defense was incredible.”

On top of Walker’s clutch tag at first in the ninth, McCarthy and Gurriel both made diving catches in the outfield. Alexander also made a diving stop at shortstop in the fourth and fired to first to retire Patrick Bailey.

“That’s how we do it here,” D-backs manager Torey Lovullo said. “We walk on the field and we’re prepared to make plays.”

Ryan Thompson (3-2) earned the win with 1 1/3 scoreless innings.

Erik Miller was the opener for the Giants and pitched a scoreless first inning. Howard entered in the second and threw 4 2/3 innings, giving up two runs and four hits.

TRAINER’S ROOM

Giants: LHP Blake Snell (left groin strain) was placed on the 15-day injured list. The two-time Cy Young Award winner left Sunday’s game against the Yankees in the fifth inning after feeling discomfort. OF Michael Conforto (hamstring) was activated to take Snell’s roster spot.

Diamondbacks: SS Geraldo Perdomo (knee) is expected to begin a rehab assignment at Triple-A Reno on Wednesday.

UP NEXT

The D-backs will start rookie LHP Blake Walston (0-0, 2.16 ERA) on Tuesday in the second game of the series. The Giants will counter with LHP Kyle Harrison (4-2, 4.15).

___

AP MLB: https://apnews.com/hub/mlb