He gave up a career-worst four home runs in a 6-4 loss on Monday night that cut the Los Angeles Dodgers' lead in the NL West to two games.
The right-hander had beaten the Nationals twice without allowing an earned run in 15 1-3 innings this season, the second time coming last month in his final start with Philadelphia. But Hernandez gave up a two-out homer to Jayson Werth in the first inning, and the Nationals were off and hitting.
"You get behind in too many counts and you've got to pay," Dodgers manager Don Mattingly said. "You help them a lot by continuing to get behind in the count."
Hernandez (2-2) gave up five runs and five hits in 4 1-3 innings. He struck out four and walked four.
"It surprised me a lot," he said through a translator. "I didn't have command of my pitches from the first inning. It was just a matter of things not working for me. It wasn't that I had lost confidence."
The Dodgers (77-61) are close behind in pursuit of the top seed, despite losing for the third time in four games.
Gonzalez (7-9) allowed three runs and three hits in six-plus innings. The left-hander was 0-5 with a 4.38 ERA in his previous nine games.
He also doubled and scored on Anthony Rendon's double off Brandon League in the seventh.
The Dodgers then had runners on the corners with two outs but Joc Pederson took a called third strike in his major league debut.
"I felt like I did a good job of controlling my emotions," Pederson said. "I was just trying to slow the game down."
The Nationals ended August with 40 homers, second-best in the major leagues behind Baltimore. They picked up where they left off to start the final month of the regular season, with Werth and Asdrubal Cabrera adding solo shots.
Span's second homer, a two-run shot on the first pitch he faced in the fifth, extended Washington's lead to 5-2. That chased Hernandez, who had walked Cabrera to start the inning before striking out Gonzalez.
The Dodgers got a two-out homer in the bottom of the first by Matt Kemp to take a 2-1 lead.
Cabrera tied it at 2 with a leadoff drive in the third. One batter later, Span hit his first homer of the game.
NATS AT DODGER STADIUM
They won for just the second time in their last nine games at Dodger Stadium dating to July 23, 2011.
Nationals: 1B Adam LaRoche left in the fifth after straining his lower back during an at-bat. He is day to day. ... OF Steven Souza Jr. (left shoulder) returned from rehab and was reinstated to the active roster. He was named International League MVP last week, having led the league in nearly every offensive category.
Dodgers: RHP Chris Perez (bone spurs, right ankle) was reinstated from the 15-day DL after making five rehab appearances with Single-A Rancho Cucamonga. INF Carlos Triunfel was designated for assignment.
Dodgers: Los Angeles recalled C Tim Federowicz, RHP Yimi Garcia, and INF-OF Alex Guerrero from Triple-A Albuquerque and selected the contract of OF Pederson from Albuquerque. Guerrero struck out as a pinch hitter and Garcia made his major league debut in the eighth.
Nationals: RHP Doug Fister (12-5, 2.55 ERA) is 0-2 with a 3.86 ERA in his last three starts.
Dodgers: LHP Clayton Kershaw (16-3, 1.73) starts. Among NL pitchers with at least 15 decisions, Kershaw and Fister (.706) rank first and second in winning percentage.