The Padres hit three home runs Sunday afternoon. Needed every one of them, too.

With the shorter, closer fence in right field coming very much into play for both teams at Petco Park, the Padres indeed played a rare game of power ball for a 6-4 win over the San Francisco Giants, pulling off a sweep of the reigning World Series champions. The Padres’ fourth consecutive victory gave them their first winning homestand of 2013, sending them off toward May and Wrigley Field for four games against the Chicago Cubs.

At the same time, the Padres continued to be a team of extremes, now having won two series by sweeps and been swept out of three series. Just a week earlier, it was the Giants winning all three from the Padres at AT&T Park.

The difference?

“It’s not all that much,” said Chase Headley, who had a solo homer and two doubles. “It’s just executing the little things, making plays defensively, getting a couple of big hits and our pitchers. It’s not a huge difference, but enough to win a series.”

For all the hitting — Nick Hundley and Alexi Amarista had the other two homers off Giants starter Ryan Vogelsong — it was a defensive play that saved the Padres from what might’ve been another late-inning tie game or worse. Chris Denorfia made a diving catch in right of a line drive by Andres Torres off Luke Gregerson with two runners in scoring position, two outs and the Padres up by two runs in the eighth inning.

“Luke and I don’t even know how he got that ball in the air,” Denorfia said. “That pitch was on the ground almost.”

Earlier in the same inning, Denorfia had come within inches of making a grab that would have denied the Giants a two-run homer by Buster Posey off relief pitcher Brad Brach. The ball bounced off the pinkie of Denorfia’s glove and the top of the new wall, the same eight-foot fence cleared by Amarista’s homer, which ultimately proved the game-winner.

“I was pretty upset I didn’t get the first one,” Denorfia said. “I didn’t have to wait long for the second one.”

Meanwhile, starting pitcher Jason Marquis produced precisely the kind of longer outing the Padres have largely lacked from their rotation, holding the Giants to two runs over 6 2/3 innings despite four walks. In the process, he gave a bit of a break to a bullpen that combined for eight innings of relief work in the 12-inning, 8-7 win on Saturday night.

“We needed it,” said manager Bud Black. “He battled his (tail) off. That was the theme of the guys (on the mound) when I took him out in the seventh — Chase, Nick, all those guys — paying him compliments for the way Jason pitched without his full command.”

Three batters into the bottom half of the first, Marquis was given a 1-0 lead on Headley’s home run to straightaway center. The homer was Headley’s 29th at Petco Park, moving him ahead of Brian Giles, placing him behind only Adrian Gonzalez (58) and Khalil Greene (34).

No sooner had Marquis given up a tying run on Brandon Crawford’s sacrifice to center than Hundley, who’d had his double-play grounder turned into a walk-off error for the win the night before, put the Padres back ahead with a two-run homer in the second.

Amarista produced a more historic first with his first home run of the season, a two-run fly to right in the fourth, boosting the lead to 5-1. The ball landed in the section between the taller, faraway wall and the shorter, closer wall that borders Petco Park’s new dimensions.

More typically, the Padres added a run in the sixth with some small ball, starting with a walk to Amarista and single by Hundley. Giants manager Bruce Bochy pulled Vogelsong, bringing in left-hander Jose Mijares to face the lefty-hitting Marquis, who bunted over the runners. A passed ball by Posey brought home Amarista.

Posey, however, came back in the eighth with a two-run homer that cut the Padres’ lead to 6-4. And, with Pablo Sandoval on base, Posey was at the plate again when Padres closer Huston Street induced a game-ending grounder.