By the fourth inning, Washington would cut the lead to 3-2, thanks to RBI hits by Paul Lo Duca, but San Francisco would add to its lead in the bottom of the fourth, when Molina hit another homer off Bergmann to make it a two-run game.
"I gave up three home runs that I was really unhappy with. It really was the difference in the game," Bergmann said. "The runs were there for us. Molina had my number today. I tried each time he came up to throw something a little different except my push wasn't there. He did a good job of hitting and he hit two balls out.
"My slider was nonexistent. I kept trying to throw it for some reason. It's not very smart. ... I kept throwing the slider more and more and I had hoped to work through the problems that I was having with it. It just wasn't an effective pitch today. I wish I didn't throw so many."
After reaching base on an error by Nationals second baseman Felipe Lopez in the fourth inning, Giants third baseman Rich Aurilia scored on a double by Omar Vizquel.
Bergmann lasted five innings and gave up the five runs -- four earned. He hasn't won a game since May 15 against the Mets.
Giants left-hander Barry Zito lasted six innings and gave up three runs on seven hits. With the score 5-2, the Nationals had Zito on the ropes in the fifth inning, but could only muster one run and that came on Willie Harris' seventh home run of the season.
Four batters later, Washington had runners on first and second and had the go-ahead run at the plate, but Jesus Flores struck out to end the threat.
"He was spotting his fastball very well tonight," Lo Duca said of Zito. "We had a couple of chances, but he tightened up on us the last couple of innings. We had him in trouble in the fifth and let him off the hook a little bit. He came out in the sixth and threw well."
San Francisco scored its final run of the game off reliever Saul Rivera in the eighth inning. With runners on first and second and one out, Aaron Rowand singled to drive in Randy Winn.
The Giants have now won five straight games against the Nationals this season, In those games, San Francisco scored fewer than five runs against Washington only once.
"We haven't beaten them this year. I don't think we have been in many of the games," Lo Duca said. "But we are playing a lot better and we are in games. We are swinging the bats a lot better. We need to come out the next couple of nights and play well because we have to go to L.A. and the Dodgers are another tough ballclub."