Loaiza struck out 11 and took a shutout into the eighth and Preston Wilson and Brian Schneider each hit a three-run homer as Washington gained a game on all three teams that they trail in the NL wild-card standings.
"They had a chance to knock us out and they didn't do it," Nationals manager Frank Robinson said of the Phillies.
Schneider's 10th homer came in the second off Gavin Floyd (1-2), who was called up from the minors to make his first start for the Phillies since April.
The Nationals hadn't score more than five runs in a game at home in exactly a month. And they had only four three-run homers in 136 games entering the day.
Yet, suddenly, the Nationals find themselves trailing the Phillies by only two games. Losses by the Astros and Marlins left those clubs a half-game behind Philadelphia.
"It hurts just like it did last night. A loss is a loss," said Phillies manager Charlie Manuel, whose club went 6-6 on its longest road trip of the season.
Now, the Phillies open up a ten-game homestand against Houston, Florida and Atlanta. Washington, meanwhile, plays its next seven games at home against Florida, then Atlanta.
Loaiza gave up a run, four hits and four walks, and matched his career high for strikeouts in improving to 10-10.
The Phillies had their chances before Jason Michaels' RBI single in the eighth, but they left two runners on in each of the first, second and sixth innings.
At one point, Loaiza retired 12 straight batters, and he improved to 9-2 in his career with three days' rest. Significantly, by going eight innings, he gave much-needed rest to a beleaguered bullpen. The outing ended a nine-game run in which no Nationals starter earned a win.
Floyd, in contrast, couldn't get his breaking ball to break early. He nearly hit Jose Guillen twice and Wilson and Vinny Castilla once each before eventually plunking Castilla in the second. Schneider drove the next pitch into the visiting bullpen.
Loaiza also struck out 11 Phillies on April 27th.