PHILADELPHIA -- Another gem by Phillies starter Cole Hamels was nearly wasted again.

Darin Ruf hit a solo homer in the eighth to break a 2-2 tie and lifted the Philadelphia Philliesto a 3-2 victory Sunday and three-game sweep over the Atlanta Braves.

"It was a good sign for Darin to go right-center like that," Phillies manager Ryne Sandberg said. "He seems to get a lot of pitches away. It's a good sign he stayed on that one, and it was a big moment. That's what he needs to continue to do."

Hamels (7-13) made just two mistakes Sunday -- two long homers off the bat of Evan Gattis-- and they nearly cost him the win.

Gattis' first home run, in the second inning, traveled 480 feet to center field. In the seventh, he tied the game with a long ball that went deep into the left-field bleachers. It was his first career multi-homer game.

"He's strong," Hamels said. "He swung with everything he had in him. I felt like I was throwing a golf ball out there and he had a driver."

They were the only two hits Hamels allowed over eight innings. He struck out nine, walked two and retired the side in order four times.

"He was outstanding," Sandberg said. "It's about time he got a late-inning run to get the W."

Gattis almost had another home run in the fifth inning, but it died at the warning track in dead center field with a strong wind blowing in.

"I guess if the 50 mile-an-hour winds didn't keep it in play, it definitely would've went off the wall," Hamels said. "Or through it."

B.J. Rosenberg earned his first career save with a perfect ninth inning.

"He took it and ran with it," Sandberg said. "He earned the spot there today, came through big time with great stuff, pounded the strike zone with strikes."

David Carpenter (3-1) took the loss for allowing Ruf's homer in the eighth.

Chase Utley doubled and Ruf singled to knock in the Phillies' first two runs in the first inning. Utley and Ruf both finished with two hits apiece.

Braves starter Paul Maholm went six innings and allowed two runs on seven hits, three walks and a hit batter. He struck out five and stranded seven Phillies baserunners.

"He gave us a great opportunity to win the game," Atlanta manager Fredi Gonzalez said. "We only had two hits. We didn't do much offensively to the whole series."

Two baserunning blunders by Cesar Hernandez may have cost the Phillies extra runs. He was picked off in the first inning and thrown out by Joey Terdoslavich attempting to go first to third in the fifth inning.

Philadelphia squandered a chance for more runs in the sixth. After the first two men reached base via a walk and an error, Freddy Galvis grounded into a double play and Hamels struck out.

B.J. Upton, who went 0 for 4, finished the series 0 for 12 with seven strikeouts. B.J. and Justin Upton are hitless in their last 32 at-bats combined.

"They pitched well all three games," B.J. Upton said. "We were in all three games, it just didn't work out. ... We're fine. We'll come back to play tomorrow."

The Braves had just 10 hits in the series.

The Phillies are 11-2 in their last 13 one-run games.

"It's great to just play well in all facets of the game, pitching, defense, swinging the bats well this series too," Ruf said. "It was nice just to see what we can do when all phases of the game are clicking for us."

Game notes

Atlanta LHP Scott Downs is considered day-to-day with a non-displaced fracture to the tip of his right ring finger. Down left Saturday's game after being hit on his glove hand with a line drive. ... Cole Hamels has gone at least five innings in 72 consecutive starts, the longest active streak in the majors. ... Braves OF Justin Upton, hitless in 16 at-bats entering Sunday, did not start. He entered as a pinch hitter in the eighth and struck out. ... Atlanta, which owns baseball's best home record at 51-20, is just 34-37 on the road. ... Philadelphia resumes its homestand Tuesday against the Padres with Roy Halladay (3-4, 7.19) on the mound. ... Atlanta heads Monday to Miami, where Kris Medlen (12-12, 3.48) will take the hill.

Copyright by STATS LLC and The Associated Press