WASHINGTON -- The Washington Nationals are hitting again and showing the resiliency that enabled them to put together numerous late-inning rallies earlier in the season.

It couldn't have come at a better time.

Anthony Rendon homered to spark a three-run seventh inning, and pinch hitter Nate McLouth came through with a tiebreaking sacrifice fly as the Nationals rallied past the Houston Astros 6-5 on Wednesday night for a two-game series sweep.

"That's kind of how we've done it all year, not necessarily lately, but we grind out at-bats," Nationals outfielder Jayson Werth said. "We got some big hits late and came from behind there after a big inning for them."

It was the 17th come-from-behind victory for Washington, which extended its National League East lead to 1 1/2 games over Atlanta and Miami. The Nationals open a four-game series against the Braves on Thursday night in Washington.

Rendon led off the seventh against Josh Zeid with his 10th home run, cutting the deficit to 5-4. The Houston native is 9-for-18 against the Astros with seven RBIs.

"He continues to swing a hot bat against us," Houston manager Bo Porter said. "We felt like Zeid was going to be able to get those first two guys and have (reliever Darin) Downs ready for (Adam) LaRoche."

Werth was walked by Zeid and raced to third on LaRoche's single off Downs (1-1).

"I knew the center fielder didn't have a chance (to catch it). The whole thing's right in front of me there, so it's a pretty easy read," Werth said.

Kyle Farnsworth came on to face Ryan Zimmerman, who grounded into a fielder's choice, beating the relay to first as Werth scored to tie it.

Ian Desmond then doubled Zimmerman to third. After Danny Espinosa was intentionally walked, McLouth's long fly to left field scored Zimmerman with the go-ahead run.

"We just create those opportunities and we're not out of a game," manager Matt Williams said. "We feel good about one swing of the bat (and) we can get back in it. And that's what happened tonight."

Aaron Barrett (3-0) got one out for the win, and Rafael Soriano earned his 15th save.

Matt Dominguez drove in two runs for the Astros, who have lost three straight.

For the second straight night, neither starter made it past the fifth inning.

Astros right-hander Scott Feldman left after five innings with a 4-2 lead. He gave up six hits and three walks while striking out five.

"Scott pitched great. Our team did a really good job of getting ahead early," Zeid said. "I had a job to do, come in and hold a lead, and I didn't do that. I didn't get ahead of guys, I left balls up in the zone, and major league hitters are going to turn around and make you feel pretty bad."

Gio Gonzalez, activated Wednesday after missing 29 games due to left shoulder inflammation, pitched five innings for Washington, allowing four runs and five hits.

"Overall his health was good," Williams said. "He got into one tough inning. Other than that, he pitched pretty good."

Gonzalez struck out six and walked three while throwing 93 pitches.

"It's something to learn from, dust the cobwebs off a little bit and get back at it," Gonzalez said. "It's definitely a work in progress."

A replay review helped Washington take a 1-0 lead in the first.

Denard Span walked and was called out attempting to steal second. Williams challenged the call, and after a replay review, it was overturned.

Span then moved to third on an infield single by Rendon and scored on LaRoche's sacrifice fly.

In the third, Werth walked, stole second and scored on Desmond's single.

With Houston trailing 2-0 in the fourth, five straight Astros reached safely. After a walk and a hit batter, Jon Singleton singled to load the bases. Dominguez had a two-run single.

Jason Castro followed with an RBI double and Jonathan Villar added a sacrifice fly to put Houston ahead 4-2.

The Nationals cut the deficit to one on Span's two-out double in the sixth.

The Astros got it right back in the seventh as Robbie Grossman scored on Ross Detwiler's wild pitch.

Game notes

The Nationals stole a season-high five bases, all in the first three innings. ... Houston RHP Brad Peacock (stomach virus) didn't make the trip to Washington and will rejoin the team Thursday when it opens a four-game series at Tampa Bay. ... RHP Jordan Zimmermann (5-3, 2.98 ERA) opposes Atlanta RHP Gavin Floyd (1-2, 2.98) in Thursday's series opener. ... Houston RHP Collin McHugh (4-4, 3.03) faces RHP Chris Archer (3-4, 3.40) on Thursday at Tampa Bay.