Cole Hamels shut down his hometown Padres on four singles in eight innings to win for the first time in nine starts, leading the Philadelphia Phillies to a 5-0 victory Sunday and a three-game sweep of bumbling NL West-leading San Diego.

The Padres have lost four straight games for the first time this season and were swept for just the second time. The Padres, who led the majors in fielding percentage (.989) coming in, committed a season-high four errors.

After being swept at home in four games by Houston, the wild card-leading Phillies had their usual success at Petco Park. They won their seventh straight game at the downtown ballpark, where they're 18-4 since it opened in 2004.

The Phillies, who came in with a 1½-game lead over San Francisco in the wild card race, remained two games behind Atlanta in the NL East.

Mike Sweeney, starting in place of slumping Ryan Howard against left-hander Clayton Richard, hit a two-run homer, his first for the Phillies since being acquired from Seattle on Aug. 4. Jayson Werth added a solo shot.

Hamels (8-10) prevailed over Richard (12-6) in a duel of lefties to win for the first time since July 11 against Cincinnati. He had gone 0-3 despite a 2.83 ERA in his previous eight starts.

Hamels retired his final 16 batters after allowing Adrian Gonzalez's single with two outs in the third. He struck out six and walked none. Ryan Madson finished the combined five-hitter as several thousand Phillies fans stood and cheered.

Gonzalez had three hits for San Diego.

Two of Philadelphia's runs were unearned. Carlos Ruiz singled with one out in the third and advanced on Richard's errant pickoff throw. He took third on Hamels' groundout and scored on Jimmy Rollins' single.

In the eighth, Ruiz hit a leadoff single and was safe at second on Richard's throwing error after he fielded Hamels' bunt. Right fielder Ryan Ludwick made a nice diving catch of Rollins' fly. But when Ludwick attempted to double Hamels off first, his throw was wide and bounced into the Padres' dugout for another error, allowing Ruiz to score.

In between, Sweeney lined a pitch over the left-field wall with two outs in the seventh. It was seventh overall.

Werth hit a solo homer off Luis Perdomo with one out in the ninth, his 18th.

Richard allowed four runs, two earned, on four hits in 7 2-3 innings. He struck out five and walked one.

NOTES: Philadelphia is 14-2 against the NL West. ... Howard is batting .121 (4 for 33) with one RBI since returning from the disabled list on Aug. 21. However, he's a career .360 hitter against San Diego, with nine homers and 45 RBIs. ... The Padres hadn't lost four straight games since Aug. 13-16, 2009. ... Padres RHP Chris Young is scheduled to make a rehab start Tuesday for Triple-A Portland at Reno as he continues to work his way back from a shoulder injury. He's been on the DL since April 12 with a strained right shoulder. ... The only other team to sweep San Diego was the Los Angeles Dodgers in mid-May, also in San Diego.