WASHINGTON -- The Braves had led for only three innings of the first four games this season against the Nationals and found themselves down two runs after the first five pitches from Tommy Hanson Sunday.

If nothing else, maybe the Braves are getting used to the feeling, and they didn’t panic.

Hanson recovered nicely from a two-homer first inning and held down the Nationals until the Braves could rally against tough left-hander Gio Gonzalez. Jason Heyward stroked a two-out two-run bases loaded single to put the Braves ahead 3-2 in the fifth inning, and Hanson, Eric O’Flaherty and Craig Kimbrel held it from there.

The Braves beat the Nationals for the first time all year and snapped a six-game losing streak to them dating back to last September’s collapse. They moved back within two games of the NL East lead.

“They’re a very good team,” Heyward said. “It’s huge for us, momentum-wise, confidence-wise.”

After an off day Monday the Braves will open a three-game series Tuesday in Miami, where the Marlins just moved into a first-place tie with the Nationals. The Marlins are 23-9 since May 1. After that, it’s a two-week interleague tour through the ever-tough AL East.

“We’ve got a lot of good teams coming up, so we need to try to build some momentum,” said Hanson, who did his part on a day he was battling stomach problems.

After giving up home runs to Steve Lombardozzi and Bryce Harper on back-to-back fastballs in the first inning, Hanson settled in for one of his better outings of the season. He used nine more pitches to get out of the first and set the tone for his most efficient game of the year.

After lasting a season-low 3 1/3 innings in his previous start against St. Louis, Hanson pitched seven innings for the fourth time this season, needing only 84 pitches. He walked none and struck out six.

“Obviously not the way I wanted to start the game but you can’t give in at that point,” said Hanson, now 6-4 after his first win since May 18 in Tampa. “You’ve got to just keep trying to make pitches and try to keep your team in the game.”

The home runs by Lombardozzi and Harper came when he was trying to establish his fastball early. After that, catcher David Ross said he started mixing in more offspeed pitches.

“Tommy did a good job of slowing them down,” Ross said. "(He was) getting sliders and curveballs and change-ups over.”

Manager Fredi Gonzalez took Hanson out before Lombardozzi and Harper got any more ideas in the eighth, and had the match-up he wanted with left-handed O’Flaherty. O’Flaherty made him sweat it out with back-to-back walks with nobody out, but shortstop Andrelton Simmons turned a double play on a groundball by Ryan Zimmerman to help O'Flaherty escape the inning.

It was the second key defensive play for the rookie, playing in his second major league game. He also gunned down Harper on a relay throw to third base trying to stretch a liner off the right field wall into a triple in the fifth inning.

“Even though we made an error, I thought we played the best defensive game we’ve played in a long time,” Fredi Gonzalez said.

Michael Bourn saved Hanson two runs with a diving catch in shallow center in the second inning, and he started the game-winning rally in the fifth by beating out an infield hit with a head-first slide.

At that point the Braves were just searching for some kind of opening after getting swept at home by the Nationals last weekend and stonewalled for seven shutout innings Saturday by Stephen Strasburg.

Bourn took second on the first of two wild pitches by Gonzalez in the inning, who then walked Dan Uggla intentionally. Then he walked Matt Diaz after starting him 1-2 to bring up Heyward with the bases loaded and two out.

Heyward has hit only .190 vs. left-handers this season and was 4-for-his-last-22 overall when he came to the plate. He shot an 0-1 fastball away to the opposite field.

“With the bases loaded, he had to come to me,” Heyward said. “So I just got a pitch over the plate and I hit it.”

The Braves snapped Gonzalez’s winning streak at five games on the day he was named NL pitcher of the month. He went 5-0 with a 2.25 ERA in May, including a 10 strikeout game May 27 in Atlanta.

“We faced Strasburg and Gio Gonzalez, some of the best pitchers in the National League, back-to-back,” said Ross, who was 2-for-2 with two walks. “To go out and put the at-bats on him we did, get his pitch count up, have them use their bullpen and get out of here with a win was really nice.”

Simmons got his first major league hit with a double down the left field line in the second inning. He would have had his first RBI but Ross is nursing a sore groin and had to pull up at third base.