Pablo Sandoval slugged a three-run homer with two outs in the ninth, ending the San Francisco Giants' wild 9-7 victory over the Washington Nationals on Tuesday night.

Ryan Zimmerman extended his hitting streak to 30 games with two singles for the hard-luck Nationals, who have lost nine straight to the Giants _ none tougher than this defeat after Washington scored six runs in the late innings.

San Francisco blew a 5-1 lead when Nick Johnson hit a three-run homer in the seventh and drove in two more runs with a weak single in the eighth for the Nationals.

After Bengie Molina hit an eighth-inning homer off Kip Wells, the Giants rallied in the ninth against Joe Beimel (0-2), Washington's setup man getting a chance to close.

Emmanuel Burriss singled and Edgar Renteria drew a walk before Sandoval cracked a 2-2 pitch into left for his third homer of the season, setting off a jubilant celebration at home plate for the Giants' 15th win in 21 games.

Sandoval thoroughly atoned for his baserunning blunder two innings earlier, when he tripped over his own feet and landed face first between second and third base while trying to stretch an extra-base hit.

Brandon Medders (2-1) got two outs in the ninth for San Francisco.

Zimmerman went 2 for 5, getting both hits off Giants starter Matt Cain while matching the fourth-longest hitting streak in the majors since 2000. He has the first 30-game streak since Moises Alou did it in late 2007, and the 26th streak of at least 30 games since Joe DiMaggio's 56-game record in 1941.

Washington's third baseman also is one game shy of the franchise-record 31-game streak by Montreal's Vladimir Guerrero in 1999.

Randy Winn and Edgar Renteria drove in two runs apiece for the Giants. Cain yielded nine hits and four runs, wasting the chance for a 4-1 start to his solid season.

Rookie starter Jordan Zimmermann allowed six hits and struck out eight during six innings for the Nationals.

Cain was solid until allowing Johnson's homer in the seventh, and struggling reliever Bob Howry gave up pinch-hitter Ronnie Belliard's two-out RBI single in the eighth to tie it.

Washington then went ahead on Johnson's slow grounder to the right side. Travis Ishikawa dived to stop it, but couldn't recover in time to make a play while Wil Nieves and Belliard scampered home.

San Francisco wasted two extra-base hits with baserunning blunders. Winn got caught attempting to take third after his two-run double in the first before Sandoval's faceplant in the seventh.

Notes:@ Johnson had his only previous five-RBI game on Aug. 8, 2003, against Seattle while he was with the Yankees. ... Giants C Bengie Molina drew his first walk of the season in the first inning. San Francisco's free-swinging cleanup hitter then struck out twice before his homer. ... CF Elijah Dukes was scratched from the starting lineup with an apparent illness, but he entered the game in the ninth.