Michael Morse and Chris Marerro chipped in with a pair of hits apiece for the Nats, who have won four straight.
John Lannan (10-13) worked five effective innings, giving up three runs on eight hits while striking out three and walking one. He won for only second time in 17 career starts against the Phillies.
John Mayberry Jr. blasted a two-run homer among his three hits and scored three runs, while Ben Francisco had three hits and an RBI for the Phils, who have dropped a season-high five consecutive games.
Vance Worley (11-3) gave up four runs on six hits in defeat, while fanning six and walking three.
"He had the ball up most of the night and it got him in trouble," Phillies manager Charlie Manuel said of his starter's outing.
Washington grabbed a 2-0 lead in the second when Ramos cranked a slider from Worley just over the wall in right-center field, but the Phils came back with two of their own in the home half.
Mayberry, Raul Ibanez and Francisco hit consecutive singles to bring in the first run of the frame. Brian Schneider then singled to load the bases before Worley knocked in Ibanez with the fifth single of the inning.
The Phillies took the lead in the third when Mayberry ripped a two-out single to left, stole second and took third when the throw from Ramos sailed into center field. He scored on a single by Ibanez for a 3-2 advantage.
Philadelphia's first lead of this series was short-lived however, as Espinosa gave Washington the lead back when he crushed a first-pitch slider deep into the seats in right to make it 4-3 in the sixth.
"His concentration is probably better," Nationals manager Davey Johnson said of Espinosa's success against the Phillies. "When you play against the best in front of a full house, you get up for it."
The Nats widened their lead in the eighth, scoring three runs and sending eight men to the plate in the inning. September call-up Justin De Fratus started the inning on the mound for the Phillies, but he walked Espinosa and Marerro before getting pulled in favor of Antonio Bastardo. With runners on first and second, Rick Ankiel dropped down a bunt in front of the mound, Bastardo scooped it up and fired to third trying to force out Espinosa, but the throw sailed wide, allowing Espinosa to score. Ramos followed with an RBI single and pinch-hitter Johnny Gomes lofted a sacrifice fly to left, scoring Ankiel to make it 7-3.
A two-run shot from Mayberry in the home eighth made it a two-run game, but Henry Rodriguez shut down the Phillies in the ninth to preserve the win and earn his first career save.
The Phillies are 52-28 at home this season...Philadelphia is a major-league best 31-14 against left-handed starters this year...The Phils are 16-5 in games which Worley starts...Manuel is three wins shy of tying Gene Mauch for the most managerial wins in Phillies franchise history...Of Espinosa's 21 home runs this season, seven have come against the Phillies...Phillies pitcher Joe Blanton made only his ninth appearance of the season when he came on in relief of Worley in the seventh.