Jayson Werth homered with two outs in the first, Denard Span and Asdrubal Cabrera homered in the third, and Span homered again with one on in the fifth -- doubling his season home run total with his second career multi-homer game. Hernandez lasted just 4 1/3 innings, allowing five hits, walking one and striking out four to go along with his career-high four home runs allowed.
The loss left the Dodgers two games ahead of the Giants in the National League West.
"They put some good swings on us," catcher A.J. Ellis said. "They made us pay on some balls that were up in the zone, probably up higher than they should've been. They're a really good team. They have a good lineup, and they've been swinging the bats extremely well lately. And they've been hitting for more power lately, as well."
"Today was just a matter of things not working for me. I know I've had success against them in the past. It wasn't that I lost confidence against them. My pitches weren't working today."
Hernandez's night was nearly a subplot, as the Dodgers mounted a rally in the ninth that led to Joc Pederson -- the club's No. 3 prospect who was called up to the big leagues for the first time on Monday, in the batter's box representing the winning run in his first big league at-bat.
Pederson had the stage, had the drama, had family in the stands, had everything he needed to make his first Major League debut the stuff of legend -- a true Hollywood debut.
Pederson ripped a 2-0 fastball right in his wheelhouse foul into the seats toward the right-field corner, and Nationals closer Rafael Soriano made sure Pederson wouldn't get a chance to hit one straighter. The right-hander spotted a 3-2 slider on the outside corner. Strike three.
"We get down to the point where you have to try to win the game," manager Don Mattingly said. "And Joc's the guy for that right there. He's a left-handed hitter, he's a guy who can hit a ball in the gap, score a run."
Pederson said the ball he lined foul was one he shouldn't have missed, one he'd like to have back.
But he said he didn't shy away from the moment. The 2014 Pacific Coast League Most Valuable Player said to be able to make his debut in that kind of pressure situation was "pretty special."
"That's when you want to be up there, when the game's on the line, whether it's in [Triple-A] Albuquerque or here," Pederson said. "You want to be in when the game matters. You want to have the chance to win the game."
Nationals starter Gio Gonzalez settled in after a two-run home run off of the bat of right fielder Matt Kemp in the first inning. It was the only hit Gonzalez allowed until the seventh inning, when back-to-back singles from Kemp and left fielder Scott Van Slyke chased him from the game.
Third baseman Juan Uribe then singled off reliever Drew Storen to drive in the Dodgers' third run, but Los Angeles wouldn't threaten again until the ninth inning.
Yasiel Puig started the ninth-inning rally with a two-out walk, coming around to score on another Uribe single, which narrowed the score to 6-4. Then pinch-hitter Carl Crawford singled to set the stage for Pederson.
Pederson's result had no impact on how his new teammates look at him, how much they respect his potential.
"I think he'll look back and he'll probably never remember his first at-bat with the success he's going to have," Ellis said.