PHILADELPHIA (AP) -- Freddy Galvis and Darin Ruf homered and Carlos Ruiz drove in go-ahead run with an eighth-inning sacrifice fly to lead the Philadelphia Phillies to a 3-2 victory over the Washington Nationals on Tuesday night.

Darin Ruf of the Philadelphia Phillies hits a home run at Citizens Bank Park in Philadelphia. (Drew Hallowell, Getty Images)

Ken Giles (3-1) struck out the side in a scoreless eighth to help the Phillies to their fifth win in six games.

Asdrubal Cabrera homered for the Nationals, who lost consecutive games for the first time since Aug. 4-5.

Cole Hamels took a lead into the eighth before giving up a leadoff homer to Cabrera. The left-hander was lifted for Giles after that batter, finishing with three runs allowed on eight hits with five strikeouts and a walk.

Gio Gonzalez (6-10) gave up three runs on six hits in six innings to extend his winless streak to nine starts.

Jonathan Papelbon pitched a 1-2-3 ninth for his 33rd save in 35 chances.