SAN DIEGO (AP) -- The ball was flying out of spacious Petco Park on Friday night - for the Philadelphia Phillies, not the hometown Padres.

Philadelphia Phillies' Cameron Rupp, right, is greeted by third base coach John Mizerock after hitting a home run against the San Diego Padres during the 12th inning (AP Photo/Gregory Bull)

Cameron Rupp hit Philadelphia's fourth home run of the game, a leadoff shot in the 12th inning that lifted the Phillies to a 4-3 victory against the skidding San Diego Padres.

Rupp drove a 90 mph fastball from Kevin Quackenbush (1-2) an estimated 416 feet to straightaway center field. It was his third of the season.

"I didn't want to walk him so I threw a pitch and he hit it over the fence. That was about it," Quackenbush said.

Domonic Brown, Ryan Howard and Cody Asche hit long home runs off Padres starter James Shields.

Hector Neris (2-0) pitched the 11th for the win. Ken Giles worked the 12th for his fourth save, allowing two broken-bat singles before striking out Jedd Gyorko to end it.

The Phillies (43-67) have won 14 of 19 since the All-Star break to tie Miami for fourth place in the NL East. The teams share the worst record in the majors.

The Padres have lost four straight and five of six.

Shields blew a 3-0 lead and was pulled two batters after allowing Asche's tying homer in the seventh. One of San Diego's big offseason acquisitions, the right-hander has only one victory in his last 12 starts.

"I made three mistakes today and they took advantage of them," Shields said. "I thought I pitched pretty well. It's been frustrating all year. We have been losing one-run ballgames a ton of times this year. We've got to be able to win those."

Brown hit a moonshot to right field with one out in the fourth. It was his fourth homer in 26 plate appearances after having zero in his previous 162.

Howard drove a ball an estimated 426 feet into the sandy play area beyond the fence in right-center with two outs in the sixth, his 19th.

Asche's shot went 415 feet to right-center, his sixth.

It was the third time Shields allowed at least three homers in a game. He gave up four at Arizona on May 8.

"I like our chances," Padres interim manager Pat Murphy said about having the lead with Shields on the mound, "but give credit to the Phillies. Four solo shots. They are playing good, as good as anybody is playing right now. Credit them."

Maikel Franco just missed clearing the left-field fence with a high, arcing fly in the sixth.

Shields pitched well otherwise, striking out eight and walking one in 6 2-3 innings. He allowed three runs and six hits.

Phillies rookie Aaron Nola yielded three runs and six hits in six innings. He struck out six and walked two.

The Padres had a chance to take the lead in the seventh. Yangervis Solarte doubled into the right-field corner and was waved home by third base coach Glenn Hoffman on Justin Upton's single to right, but was out by 10 feet on a throw by Brown.

Murphy challenged the call but it was upheld after a replay review. Murphy apparently thought Rupp blocked the plate.

Murphy had no problem with Hoffman sending Solarte.

"I think you've got to. It's all based on the jump he gets off the bat. That line drive was struck well and strong. He had to make a perfect throw. Glenn is one of the best third base coaches around. He made the decision to do that and I stand behind him 100 percent," Murphy said.

San Diego took a 3-0 lead on an RBI single by Derek Norris in the second and a two-run triple by Upton in the third. Brown missed Upton's fly ball as he was retreating toward the wall. Alexi Amarista and Solarte, aboard on consecutive singles, scored.

TRAINER'S ROOM

Phillies: 2B Chase Utley was activated from the 15-day disabled list. INF Cesar Hernandez, who was filling in for Utley, will see playing time at shortstop and third base. SS Freddy Galvis could play center field if Hernandez moves to shortstop.

Padres: RHP Brandon Morrow (shoulder) is consulting with team doctors to decide whether surgery or rehabilitation is his best option.

UP NEXT

Phillies: LHP Adam Morgan (2-3, 4.46 ERA) is scheduled to start the middle game of the series.

Padres: RHP Tyson Ross (8-8, 3.37) goes for his third straight win.

(© 2015 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed)