WASHINGTON -- Cristian Guzman picked a nice time to break out of his ugly slump.
"We started getting the little hits in there and the line drives came," said Elijah Dukes, who had an RBI double in the big inning. "That's the kind of thing the little hits get. The hits are going to bring the line drives and the longball."
Guzman was in a 7-for-45 skid before his hit off Merkin Valdez gave the Nationals a 6-5 lead.
Washington snapped a six-game losing streak and avoided its first seven-game slide since starting the season 0-7. The six-run inning tied its season high.
The Nationals' rally came after a below-average start from Giants right-hander Tim Lincecum. The reigning NL Cy Young Award winner struck out seven in 6 1/3 innings, allowing four runs, two earned, and eight hits.
"We knew, we'd lost six games in a row and we were going to try to snap it against Lincecum," Washington manager Manny Acta said. "We said, 'He's good, but we're good too."'
Washington catcher Josh Bard struck the first blow, hitting his first home run since July 27, 2008, in the second inning. It was the second homer Lincecum has allowed in 11 games this year.
The Nationals scored another run in the third and two in the sixth against San Francisco's ace.
"I shouldn't have left the game with a 5-4 lead," Lincecum said. "I should have been way better than that."
Ron Villone (3-0) pitched 1 2/3 scoreless innings to get the win for the Nationals, who fired pitching coach Randy St. Claire -- the longest-tenured member of their staff -- before the game. Steve McCatty was promoted from Triple-A Syracuse to replace St. Claire.
Aaron Rowand led off the first with a home run and San Francisco carried a 5-4 lead into the eighth.
The Nationals opened their big inning with four consecutive singles. Pinch-hitter Alberto Gonzalez tied it before Guzman put Washington ahead. Ryan Zimmerman added a two-run double, Dukes doubled in a run and Wil Nieves had a sacrifice fly.
"The floodgates opened up, and we couldn't stop them," Giants manager Bruce Bochy said.
Bob Howry (0-3) recorded just one out for the Giants, and was charged with three runs and three hits.
San Francisco took advantage of Washington's shoddy defense to take the lead in the fifth inning. The Nationals have committed 50 errors this season, worst in the majors.
After singles by Fred Lewis and Juan Uribe and a sacrifice by Lincecum, Craig Stammen walked Rowand on a pitch in the dirt that got past catcher Bard.
Bard slid to pick up the ball to the left of home plate and threw past Stammen trying to prevent Lewis from scoring. Uribe also scampered home on the play and Randy Winn singled in Rowand to give the Giants a 4-2 lead.
Stammen allowed five runs, four earned, and seven hits in six innings.
Villone has not given up a run in 14 2/3 innings this year. ... Nationals C Jesus Flores was diagnosed with a stress fracture in his right shoulder and may miss the season. ... Dukes was reinstated from the 15-day disabled list before the game. RHP Kip Wells was put on the 15-day DL retroactive to May 31 with a groin strain. ... Giants LHP Randy Johnson will start Wednesday in his first bid for 300 career wins. ... Lincecum got his 500th career strikeout against Guzman in the first inning.