PHILADELPHIA -- The Philadelphia Phillies are suddenly hot. The Washington Nationals, just as suddenly, are not.

Carlos Ruiz drove in the go-ahead run with a sacrifice fly in the bottom of the eighth Tuesday night as the Phillies beat the Nationals 4-3.

Second baseman Freddy Galvis and first baseman Darin Ruf homered for Philadelphia, which won for the fifth time in six games. The Phillies also secured their third consecutive series victory, the first time they have done that since winning four in a row in July 2013.

"Guys are playing hard," Phillies manager Ryne Sandberg said. "We happen to be pitching well and getting some offense and key stuff, but the guys are playing it a game at a time, to win the game. In a lot of ways it's a credit to the veteran guys, but the guys are playing hard and it's good to see this time of year, with where we're at."

Sandberg started four bench players -- Ruf, Galvis, third baseman Andres Blanco and left fielder Grady Sizemore -- while resting the likes of Ryan Howard, Chase Utley, Cody Asche and Domonic Brown. Galvis, Ruf and Sizemore each went 2-for-3 while scoring a run, and Blanco contributed some strong defense at third.

All of them, Sandberg said, provided "good energy."

The Nats, meanwhile, are suddenly floundering. Winners 12 times in 13 games entering the series, they lost for the second straight night.

Second baseman Asdrubal Cabrera hit a game-tying homer off Cole Hamels in the top of the eighth for Washington, but the Phillies pushed across the decisive run in the bottom of that inning.

Philadelphia center fielder Ben Revere led off by grounding to shortstop Ian Desmond. Desmond threw high to first baseman Kevin Frandsen, but Revere was called out by first base umpire Gary Cederstrom. The Phillies challenged the call, and after a replay review it was ruled that Desmond's throw pulled Frandsen off the base. Desmond was charged with an error.

Revere stole second, took third on a fly ball to right by shortstop Jimmy Rollins and scored on a fly to center by Ruiz, the catcher.

Asked later about the replay review, Sandberg said, "It looked like a tough play -- bang-bang, regardless -- but it was an easy one to look at. It came in, obviously, big in the game."

Washington manager Matt Williams saw it differently.

"It looked like (Frandsen's) toe was on the bag," he said. "It was pretty close both ways."

Frandsen's view?

"I don't think it matters what I think," he said. "We just have to live with it. It's a play that's tough to make."

Ken Giles (3-1) struck out the side in the eighth to earn the victory. Jonathan Papelbon worked a perfect ninth for his 33rd save this season and his 100th as a Phillie, tying him with Brad Lidge for fourth on the team's all-time list.

Tyler Clippard (7-3) took the loss for Washington.

Hamels carried a 3-0 lead into the seventh but gave up RBI singles to catcher Wilson Ramos and Frandsen, a former Phillie. Hamels, who departed after Cabrera's homer, struck out five and walked one while allowing three earned runs or fewer in his 17th straight start.

Washington starter Gio Gonzalez pitched six innings and allowed three runs and six hits. Gonzalez, who struck out four and walked one, is winless over his last nine starts.

The game was scoreless until the bottom of the fifth. Sizemore led off the inning by tripling to center, and Galvis ripped an 0-1 fastball from Gonzalez into the left-field seats, making it 2-0.

It was the first homer of the season for Galvis, who was just 2-for-44 entering the game, and the 10th of his three-year career.

Ruf's homer in the sixth made it 3-0.

NOTES: The Phillies have won 13 of their last 19 home games. ... Phillies RHP Ken Giles has struck out 28 of the 62 hitters he has faced at home, a 45.1-percent strikeout rate that trails only Cincinnati's Aroldis Chapman (60.4) and Atlanta's Craig Kimbrel (49.6). ... Washington LF Scott Hairston went 1-for-2 with a walk against Phillies LHP Cole Hamels and in his career is 18-for-46 (.391) with five homers off Hamels. ... With his 12 strikeouts Monday against the Nationals, Philadelphia RHP A.J. Burnett became the first pitcher in major league history to fan that many in a game for five different teams. ... Washington 2B Asdrubal Cabrera, who left Sunday's game against San Francisco with tightness in his rib cage, returned to the starting lineup Tuesday.