Marco Scutaro hit an RBI single in the 10th inning after Buster Posey's tying double in the ninth, and the San Francisco Giants rallied to beat the Arizona Diamondbacks 9-8 on Monday.

Brandon Crawford beat out a single to short leading off the final inning and moved to second when Brett Pill dropped his first career sacrifice bunt. Angel Pagan grounded out to first to advance Crawford to third.

Scutaro sent the final fastball from Bryan Shaw (1-5) past diving third baseman Chris Johnson for San Francisco's seventh walk-off win. Scutaro also doubled and scored the tying run in the ninth to help hand J.J. Putz his second straight blown save.

Putz had converted 19 consecutive saves until blowing a chance against the Dodgers on Sunday.

Sergio Romo (4-2) pitched a perfect 10th for the Giants.

Scutaro hit a double to left leading off the ninth against Putz and moved to third on Pablo Sandoval's groundout. Posey doubled down the left-field line to score Scutaro.

Putz intentionally walked Hunter Pence and struck out Xavier Nady swinging. With a full count and an announced sellout crowd of 42,045 roaring to its feet, he struck out Hector Sanchez and quieted AT&T Park.

At least for a little.

The Giants, coming off a 5-1 road trip against Chicago and Houston, returned home with a 4½-game lead over the Dodgers in the NL West. The loss gave Arizona, now 10½ back of San Francisco, another blow to its fading playoff hopes.

The Giants handed starter Barry Zito plenty of support in the first inning.

On a relatively warm, windless day by San Francisco standards, Posey's fly carried over the head of right fielder Justin Upton and off the scoreboard for a double that scored Scutaro. Pence followed with a two-run triple and Sanchez's infield single gave the Giants a 4-0 lead.

Zito struck out five of the first seven he faced and had Arizona's hitters chasing pitches all over the zone and in the dirt — until he didn't.

In the fifth, Chris Johnson sent an 80 mph cutter over the wall in left for his 14th home run, a two-run shot that sliced San Francisco's lead to 4-2. Zito was replaced by Guillermo Moto after allowing consecutive singles to Upton and Jason Kubel to open the sixth.

Arizona sent ten batters to the plate in the inning while getting an RBI from five different players — Johnson, Paul Goldschmidt, Willie Bloomquist, Chris Young and Aaron Hill — to take a 7-4 lead. Goldschmidt's double was the only extra-base hit.

Zito gave up four runs and seven hits and struggled to go deep for the second straight start. Arizona starter Patrick Corbin followed suit, allowing four runs and seven hits in five innings. Both struck out six and walked none.

Zito left with a 4-2 lead, a light ovation from fans and a mess Mota couldn't clean up. Mota, who came back last week following a 100-game suspension for his second positive drug test, gave up two hits and a walk before the boo-birds pelted the pitcher until he exited.

Sandoval singled home Angel Pagan in the seventh as San Francisco began its own rally.

After Upton added an RBI single for Arizona in the eighth, Crawford hit an RBI double and pinch-hitter Brandon Belt followed with a two-out single to bring the Giants within a run. David Hernandez, who started the inning, got Pagan out on hard line drive to right field for the final out of the eighth.

NOTES: Xavier Nady's liner in the first ricocheted off Corbin's right foot and second baseman Hill caught the ball for the second out of the inning. ... Aubrey Huff's pinch-hit single for the Giants in the seventh was his first hit since June 10 against Texas. ... The announced crowd of 42,045 was the 150th consecutive sellout for San Francisco. ... Giants LHP Madison Bumgarner (14-9, 3.07 ERA) starts against Arizona RHP Trevor Cahill (9-11, 4.02 ERA) on Tuesday.