Hamels (8-10) recorded his first win since July 11 despite pitching very well in the interim. The lefty, who has a 2.46 ERA in his last nine starts, finally earned the win in one of them after allowing just four hits while fanning six without walking a batter.
Mike Sweeney hit a two-run homer — his first with the club — for the Phillies, who maintained their two-game deficit in the NL East after Atlanta rallied for a 7-6 win over Florida earlier Sunday. They maintained their 1 1/2-game lead in the wild card race over San Francisco, which beat Arizona.
Jayson Werth added a solo shot.
Adrian Gonzalez had three of San Diego’s five hits, as the Padres suffered their fourth straight loss — a season-worst. The Padres, who have the best record in the NL, were swept in a series for only the second time this season.
Clayton Richard (12-6) lost for the first time since July 22 — a string of six starts and five wins — after giving up four runs — two earned — on four hits and one walk while fanning five in 7 2/3 frames. San Diego was hampered by a season-high four errors.
The Padres’ lead in the NL West still stands at a sizeable five games over the Giants.
The Phillies’ first seven batters were retired, but the visitors managed a run in the third.
Carlos Ruiz reached on an infield single and moved to second when Richard’s pickoff attempt bounced past first base. He went to third on Hamels’ groundout and came around to score on Jimmy Rollins’ base hit to right.
In the seventh, Werth worked a two-out walk, and Sweeney followed him with a bullet down the left-field line for a two-run homer and a 3-0 advantage.
Philadelphia padded its lead in the eighth when Ruiz singled leading off, moved to second when Hamels reached on an error and scored on Ryan Ludwick’s throwing error after a spectacular diving catch in right.
Hamels, who labored through the first two innings — needing 50 pitches, settled down to shut down the Padres’ offense. After allowing a two-out single to Gonzalez in the third, the lefty retired the final 16 batters he faced, using only 65 pitches to finish the final six innings of his outing.
Werth’s ninth-inning solo shot accounted for the final margin.
The Phillies have won seven straight in San Diego and won the season series, 5-2…The Padres had won on each of their last 10 Sunday games…Philadelphia has won 10 of its last 11 day games…The Phillies scored more than three runs for the first time since last Sunday against Washington. They had scored three or fewer in six straight contests…San Diego’s Chris Denorfia (back) was scratched from the lineup…In this series, Phillies starters went 22 innings and allowed just two runs, an ERA of 0.82…The Padres suffered their first four-game losing streak since August 13-16, 2009.