SAN FRANCISCO -- The San Francisco Giants are still doing things the hard way.
"Obviously that happens quite a bit up here," said backup catcher Chris Stewart, who scored the winning run less than two weeks after being called up to replace injured Buster Posey. "We've done some crazy things this year and some crazy things last year. We're never out of a game."
San Francisco, which squandered scoring opportunities in the ninth and 10th, has eight walkoff wins this season, second-most in the majors.
Sanchez has two game-ending hits this season and seven for his career.
"He's such a good hitter, he uses the whole field," Giants manager Bruce Bochy said. "You know he's going to put it in play. We had the right guy up there."
Stewart, who entered the game as a pinch-hitter in the 10th, drew a leadoff walk against Craig Stammen (0-1) to start the winning rally. After Stammen struck out pitcher Javier Lopez, Andres Torres singled to right.
Miguel Tejada hit into a fielder's choice to move Stewart to third before Sanchez lined a 1-1 pitch from Stammen down the line in right.
Lopez (3-1) retired all four batters he faced for the victory.
Mike Morse homered for the second straight game, but Washington's bullpen struggled.
Both teams missed chances to win before Sanchez's single. The 2006 NL batting champion also had a walkoff winner against Colorado on May 6.
The game lasted nearly 4 1/2 hours and ended at 11:44 p.m. local time.
"This is the first team I've been with a team that has so many moments like today," Tejada said. "The reason we have these kind of games is because of the bullpen we have. We don't panic."
Washington stranded a runner at second in the 11th and left the bases loaded in the 12th.
The Nationals wasted a solid effort by starter John Lannan, who allowed two hits through the first six innings -- Torres' leadoff single in the first and a bunt by Tejada in the sixth. The Nationals' left-hander, who lost to the Giants on April 30, had extended his streak to 19 innings without allowing an earned run. The streak ended when Aaron Rowand led off the seventh with a homer to left that trimmed San Francisco's deficit to 4-1.
"Sometimes four is enough, sometimes it's not," Washington manager Jim Riggleman said. "John did a great job, but it kind of fell apart on us."
The game was delayed for about five minutes in the third inning when home plate umpire Gerry Davis was injured after getting hit by the mask of Washington catcher Ivan Rodriguez. Tejada hit a foul ball that deflected off Rodriguez's mask and pushed it into Davis' arm, opening a deep cut.
Davis received treatment in the Giants' dugout and returned, but left again in the bottom of the fifth. Third base umpire Todd Tichenor replaced Davis behind the plate, and the game continued with three umpires.
It wasn't a much better night for Giants starter Tim Lincecum.
San Francisco's two-time NL Cy Young Award winner struck out the side in the first before giving up a homer to Morse leading off the second. Lincecum came back to fan Danny Espinosa and Jerry Hairston to reach 1,000 career strikeouts, becoming just the eighth pitcher since 1900 to reach the milestone in his first five seasons.
But Lincecum lasted only five innings and had five strikeouts with three walks. It's the shortest outing by the San Francisco ace since he left after just 3 2/3 innings against San Diego on Aug. 15, 2010.
Morse, who hit his second career grand slam of the season in Sunday's 11-inning win over Arizona, got to Lincecum again with a two-run double in the third to make it 4-0. Morse, a former prospect with Seattle now prospering in Washington, continued his torrid pace and is batting .375 with six doubles, eight home runs and 24 RBIs in 28 games since May 1.
The Giants scored three times in the eighth after Lannan left the game. They missed a chance to win it in the ninth after Torres drew a leadoff walk, was sacrificed to second and stole third. Henry Rodriguez, who gave up Nate Schierholtz's game-tying pinch-hit single in the eighth, got Cody Ross to hit a grounder and shortstop Ian Desmond threw Torres out at home. Rodriguez retired Huff to end the inning.
San Francisco put two runners on in the 10th against Cole Kimball, but again failed to score.
Over his past two starts, Lincecum has a 7.94 ERA. ... Morse's home run was the first allowed by Lincecum at AT&T Park this season. ... The Giants rested injured 3B Pablo Sandoval and gave him the night off while rehabbing with Triple-A Fresno. Sandoval had some soreness in his right hand -- the same hand he suffered a broken hamate bone in -- but still took part in all pre-game work. ... IF Mike Fontenot (groin strain) is expected to begin running and taking batting practice within the next week. ... LHP Barry Zito was scheduled to make an 85-pitch start for Class A San Jose on Monday, the first step in his rehab assignment.