PHILADELPHIA — Just as his team has done over a grueling 20-game stretch, Wilson Ramos kept battling during a key at-bat on Wednesday night.

Ramos came back from an 0-2 hole to deliver the go-ahead RBI during an eight-pitch at-bat, Jayson Werth homered and Gio Gonzalez pitched six strong innings to lead the Washington Nationals to a three-game sweep of the Philadelphia Phillies with a 2-1 victory Wednesday night.

“Wilson battled and battled,” Nationals manager Dusty Baker said. “That was a big hit, big RBI, big at-bat.”

Ramos helped NL East-leading Washington set a franchise record with its ninth straight victory over the Phillies. The Nationals remained nine games in front of the second-place Mets, who beat Miami 5-2.

“I was mainly concentrating on putting the ball in play and just focused on that,” Ramos said through an interpreter.

The Nationals finished a stretch of 20 games in as many days with an 11-9 mark. Washington is idle Thursday for its first day off since Aug. 11.

“I’m proud of these guys because that’s a tough stretch,” Baker said. “The main thing is we finished strong. They gave me all they had.”

Freddy Galvis homered for Philadelphia, which has lost seven of nine. The Phillies have dropped eight of their last nine games at home to Washington.

“Nine hits in a three-game series isn’t going to cut it,” Phillies manager Pete Mackanin said. “We’re just not hitting the ball. We need more offense, obviously.”

Gonzalez (10-9) gave up one run and two hits with four strikeouts and a walk.

“He kept the ball down,” Baker said. “That was a big game for him.”

Adam Morgan (1-9) lost his ninth straight despite arguably one of his best outings of the season.

The game was played through a persistent drizzle.

Shawn Kelley got the only batter he faced, Maikel Franco, to ground out to end the game for his seventh save. Regular closer Mark Melancon got the night off.

The Nationals went ahead in the seventh. Anthony Rendon doubled with two outs. Morgan looked like he had Ramos struck out, but home plate umpire Mark Carlson didn’t call a borderline 0-2 pitch a strike. Ramos battled back before eventually lining a 3-2 pitch into right field to score Rendon and end the night for Morgan.

MORE ON MORGAN

Morgan gave up two runs and three hits while striking out five and walking none in 6 2/3 innings. He retired 13 straight at one point and produced nine groundball outs. He hasn’t won since May 15.

“He did a great job with his offspeed stuff and really located extremely well,” Mackanin said. “The best I’ve seen him, probably ever.”

Morgan credited veteran catcher A.J. Ellis for helping him simplify the game plan.

“He’s very, very knowledgeable,” Morgan said. “I think it was great to see him over here, just to see how he works and how he goes about is business is very encouraging.”

Morgan possesses the longest losing streak in the majors. The last Phillies pitcher with a longer skid was Kyle Abbott, who lost 11 consecutive games during the 1992 season.

WERTH GOES DEEP

Werth gave the Nationals a 1-0 lead with one out in the first inning when he crushed a pitch 455 feet into the camera well in straightaway center for his 20th homer of the season.

It was his eighth homer in August, tying a career-high. He said it also was the longest homer he’s hit in Citizens Bank Park.

“I’ve been in some pretty cool places in this ballpark but never there,” said Werth, who hit 95 homers in four seasons with the Phillies from 2007-10.

FOR STARTERS

Werth’s homer continued a dominant first-inning trend for Washington against Philadelphia this season. The Nationals have scored in the first inning in four consecutive games against the Phillies and have a total of 17 first-inning runs in 15 games this season.

TRAINER’S ROOM

Nationals: Baker gave rookie OF Trea Turner the day off to rest. Turner has been on a tear in August, tying a Nationals rookie record for hits in the month with 45 while reaching base in 20 straight games.

UP NEXT

Nationals: The Nationals head to New York for a three-game series against the Mets that begins Friday night with RHP A.J. Cole (0-1, 4.97) against Mets RHP Noah Snydergaard (12-7, 2.55).

Phillies: After a day off, the Phillies open a three-game home series against Atlanta on Friday night with RHP Jeremy Hellickson (10-8, 3.80) facing Braves RHP Joel De La Cruz (0-7, 4.66).