Hamels (10-9) gave up a run and five hits in eight innings with a walk and 10 strikeouts.
Lidge surrendered Ian Desmond's ninth-inning RBI groundout before earning his 30th save.
Hamels also hit an RBI single.
Jimmy Rollins had two hits and one RBI.
Carlos Ruiz had one RBI, while a run scored on Tyler Clippard's seventh-inning wild pitch for the Phillies, who have won five straight and 15 of 18 against the Nationals.
Elijah Dukes led Washington with two hits and one RBI.
Five others had one hit for the Nationals, who are four defeats shy of their second straight 100-loss season.
Losing pitcher Ross Detwiler (0-6) gave up a run and four hits in five innings with a walk and six strikeouts.