The Nationals took a 5-0 lead through two innings, but had only a one-run advantage heading into the ninth. They picked up three insurance runs in that inning on a two-RBI single from Jayson Werth and Harper's double.
Washington maintained a four-game lead over Atlanta at the top of the National League East with seven to play.
The win went to John Lannan (4-0), who gave up five hits and two runs over 5 1/3 innings.
Jimmy Rollins hit his 23rd homer for the Phillies, who have lost three out of four.
Kyle Kendrick (10-12) lasted only two-plus innings in the loss. He was roughed up for five runs on five hits.