PHILADELPHIA (AP) -- Freddy Galvis was just trying to drive the ball up the middle. Fortunately for the Philies, he did much more.
Galvis hit a game-ending homer with one out in the ninth inning to lift Philadelphia to a 6-5 win over the Atlanta Braves on Saturday night.
Atlanta had trailed 5-3 going into the ninth, but Andrelton Simmons hit a two-out two-run homer off Jonathan Papelbon (5-1), who blew his seventh save in 32 opportunities.
Galvis, who had four hits, got Papelbon the win by connecting on a 1-0 pitch from Freddy Garcia (0-1) into the seats in right field. It was the first four-hit game for Galvis, who had been 0-for-7 since being recalled from Triple-A Lehigh Valley on Sept. 3. It was his fifth homer of the season.
''My approach was to stay to the middle, to be on base,'' Galvis said. ''That pitch was a hanger and I made a good swing. Thank God I hit a homer. It feels really good to hit a walkoff homer - the best feeling.''
It was the second career walkoff homer for Galvis, who also connected off Reds closer Aroldis Chapman on May 19.
''He just reacted to a pitch and got a hold of it, resulting in the home run without a big home-run swing,'' Philadelphia interim manager Ryne Sandberg said. ''I think the hits leading up to the home-run swing all worked. That's his game, for me, is staying on top of the ball and using the whole field with the line-drive stroke.''
Carlos Ruiz singled, doubled and drove in three runs, and Cesar Hernandez and Kevin Frandsen each had three hits for the Phillies.
Freddie Freeman had two hits and two RBIs for NL East-leading Atlanta, which dropped its third straight.
''We battled back and tied it but Freddy Galvis got us,'' Braves manager Fredi Gonzalez said. ''We had opportunities but haven't had that bloop single or ground ball through the middle, but we'll keep plugging away.''
Kyle Kendrick was in line for the victory before the ninth. Kendrick, who had lost a career-high tying four-game losing streak, retired the first six Braves before scuffling in the third inning. Freeman's two-run double staked Atlanta to a 2-0 lead.
The Phillies tied it in the bottom of the inning on Ruiz's two-run single. And Ruiz's fifth-inning double put Philadelphia ahead 3-2. Galvis also had an RBI single in the fifth to give the Phillies a two-run advantage.
Chris Johnson's sixth-inning double pulled Atlanta within 4-3, but the Phillies bullpen held Atlanta scoreless until the ninth. Justin De Fratus and Jake Diekman combined to allow one hit in two scoreless innings before turning the ball over to Papelbon.
Frandsen's RBI single in the eighth put the Phillies back up two runs.
Kendrick matched a career high with eight strikeouts in six innings. The right-hander allowed four hits and walked three. He had been 0-4 with a 5.27 ERA in his last five starts.
Braves rookie left-hander Alex Wood gave up four runs on nine hits in 4 2-3 innings.
''It's very frustrating,'' Wood said. ''I'm trying to help my team clinch a pennant. I'm not doing exactly what I want to do when I go out there.''
The Upton brothers continued to struggle for Atlanta. B.J. Upton went 0-for-4 with four strikeouts while Justin Upton was 0-for-3 with a pair of strikeouts. The Uptons have combined to go hitless in their last 27 at-bats.
''At least we battled back into the game,'' Simmons said. ''If we played any more innings, we might have won it.''
Notes: A day after playing in a swift 2 hours, 14 minutes on Friday night, the teams took 3 hours, 18 minutes to finish Saturday's game. . Atlanta left-handed reliever Scott Downs left after taking a Chase Utley line drive off his right hand in the sixth inning. He suffered a non-displaced right ring finger fracture. . Atlanta left-hander Paul Maholm (10-10, 4.41) faces Phillies lefty Cole Hamels (6-13, 3.50) in the finale of the three-game series at 1:35 Sunday afternoon.