Carlos Ruiz struck the deciding blow with a three-run double in a four-run fifth inning, and the Philadelphia Phillies nearly wasted another solid effort from Cole Hamels in a 5-4 victory over the Washington Nationals in the middle test of a three-game series.
John Mayberry homered and Chase Utley drove in the other run for the Phillies, who have taken six of their last eight.
"We're trying to finish strong," Ruiz said. "We know we don't have a shot to go to the playoffs, but we want to play real hard."
Hamels (8-13) pitched into the seventh inning, and despite exiting with a four-run lead, was eventually tagged with eight hits and four runs -- three earned -- with five strikeouts. Jonathan Papelbon later turned in a scoreless ninth for his 27th save.
It was enough for Hamels to best fellow lefty Gio Gonzalez (10-7), who served up nine hits and four runs over six full frames.
"To see this one loss feels like a big blow to the stomach," Gonzalez said. "We're not counting ourselves out. We still have a chance."
Jayson Werth, Ian Desmond and Bryce Harper each knocked in a run for the Nationals, whose seven-game win streak came to an end. Denard Span collected three hits and scored twice to extend his hitting streak to 25 games.
Washington also fell 5 1/2 games behind Cincinnati, which topped Milwaukee earlier Saturday, for the final NL wild card berth.
Hamels departed after loading the bases thanks to three straight hits to begin the bottom of the seventh. Werth's grounder to third against Justin DeFratus turned into a force at home, then a deep sacrifice fly to center from Desmond brought the Nats within 5-2. A shallow single to center from Harper plated another run, and when Phils center fielder Cesar Hernandez bobbled the ball, a second run came in.
Harper then stole third with Wilson Ramos at the plate against B.J. Rosenberg, but Ramos fanned to end the inning.
Jake Diekman subbed for Rosenberg with two gone in the eighth, and stranded a runner on second by spearing a bouncer at the mound from Span and throwing to first for the final out.
Papelbon allowed a leadoff double to Ryan Zimmerman, but retired the next two batters before walking Harper intentionally. Ramos then hit a sharp grounder up the middle, but shortstop Jimmy Rollins made the play on a hop and threw to first to end the game.
Washington scratched out a run in the first, as Span led off with a single, stole second, went to third on a wild pitch and scored on a Werth fly to left center.
Mayberry's one-out shot to left in the fifth tied the game. Hamels and Hernandez then singled, and a walk to Utley loaded the bases ahead of Ruiz's double that make it 4-1.
Rollins greeted Ian Krol with a double in the seventh, took third on a wild pitch and scored on an Utley single. Erik Davis then came on in relief and allowed a two-out ground-rule double to Cody Asche, but retired Freddy Galvis on a grounder to first to keep it a four-run margin.
Despite Saturday's victory, the Phillies have just two wins in their last 10 games at Nationals Park ... The Phils improved to 5-18 in their last 23 road games overall since July 20 ... Philadelphia has won seven consecutive starts made by Hamels (8/12-9/14), their longest such streak since Apr. 15-May 28, 2012, when the club won nine straight starts by the veteran lefty.