Ankiel's first blast, a solo shot in the first inning, put the Nats ahead to stay and his second long ball in the fifth gave Washington a 3-1 advantage.
Hernandez (6-10) yielded only one run on six hits. He didn't issue any walks and struck out three as he broke a personal five-game winless streak. The right-hander tossed 55 of his 81 pitches for strikes.
Todd Coffey and Ryan Mattheus each registered a shutout inning of relief and Drew Storen racked up his 27th save despite allowing a ninth-inning run on Dan Uggla's second solo homer of the game.
Uggla finished 3-for-4 for the Braves, who dropped the opener of a three-game road series.