PHILADELPHIA — If Philadelphia Phillies left-hander Adam Morgan continues to pitch like he did against the Washington Nationals, it’s only a matter of time before he ends his losing streak.

Morgan pitched 6 2/3 strong innings, allowing two runs and three hits, but he couldn’t get Wilson Ramos out with two outs during a crucial at-bat in the seventh inning as the Phillies were swept by Washington 2-1 on Wednesday night.

Morgan (1-9) lost his major league-leading ninth straight game but left encouraged by his performance. He struck out five and walked none.

“It was fun,” he said. “It was just a simple game. The use of the two-seamer has helped me a lot. Just trying to keep the ball down.”

Morgan 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,” Phillies manager Pete Mackanin said. “The best I’ve seen him, probably ever.”

Morgan credited recently acquired 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.”

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 Washington.

“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,” 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.”

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.

WERTH GOES DEEP

Werth gave the Nationals a 1-0 lead with one out in the first inning when he crushed a pitch 453 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.

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).