Kyle Schwarber hit his 25th home run and ended the game with a 12th-inning sacrifice fly, giving the Philadelphia Phillies a 7-6 win over the San Diego Padres on Sunday.

The defending NL champions won three games in a row over the Padres on the heels of a three-game losing skid, including a series-opening loss to San Diego to start the second half. The Padres, who lost in the NLCS to the Phillies last fall, dropped to 44-50, including 19-27 on the road.

Philadelphia (51-42) overcame a 3-0 deficit, then wasted a 5-3 lead when pinch-hitter Fernando Tatis Jr. had a two-run single in the eighth off Gregory Soto. Juan Soto hit a sacrifice fly in the 10th against Matt Strahm, but Bryce Harper hit a two-out tying single off Josh Hader in the bottom half.

CLICK HERE FOR MORE SPORTS COVERAGE ON foxnews.1eye.us

Kyle Schwarber gets mobbed by teammates

Philadelphia Phillies Kyle Schwarber celebrates with teammates after hitting a game-winning RBI-sacrifice fly against San Diego Padres relief pitcher Tim Hill during the 12th inning of a baseball game, Sunday, July 16, 2023, in Philadelphia.  (AP Photo/Matt Slocum)

"A really good pitcher and a really good hitter, and Harp got the best of things in this round," Phillies starter Zack Wheeler said. "It’s what you expect of your big guy."

With automatic runner Edmundo Sosa on second base starting the 12th, Johan Rojas sacrificed against side-arming left-hander Tim Hill (1-4) and Schwarber hit a 304-foot fly to Soto in left. Sosa slid home easily ahead of Soto’s throw.

Jeff Hoffman (3-1) retired six straight batters in the 11th and 12th, stranding automatic runners both times.

"He was big for us," Wheeler said. "It’s very hard to not let them score there, especially when a guy gets to third with one out. Really tough."

San Diego manager Bob Melvin was ejected in the 12th by crew chief Dan Bellino after a pitch-clock violation call, Melvin’s fifth ejection this season and the 59th of his managing career.

CARDINALS' JACK FLAHERTY WINS FOURTH STRAIGHT START WITH VICTORY OVER NATIONALS

Bryce Harper reacts

Philadelphia Phillies Bryce Harper reacts after hitting a run-scoring single during the 10th inning of a baseball game against the San Diego Padres, Sunday, July 16, 2023, in Philadelphia.  (AP Photo/Matt Slocum)

"I thought we were going to pull out a `W' tonight. Played great defense. Put together some good at- bats, but we weren’t quite able to finish it," Padres starter Seth Lugo said. "One thing they’re good at is not missing mistakes, and I made a couple of mistakes and paid the price for it."

Wheeler allowed three runs and five hits in seven innings with seven strikeouts and no walks.

Ha-Seong Kim and Xander Bogaerts built an early lead when each hit his 11th homer, Kim connecting in the first and Bogaerts in the fourth. Trent Grisham made it 3-0 with an RBI double in the fifth.

Bryson Stott homered in the bottom half and Schwarber went deep to spark a four-run sixth. J.T. Realmuto’s two-run double chased Lugo and Drew Ellis had a bases-loaded walk off Tom Cosgrove.

GUARDIANS' SHANE BIEBER SHUT DOWN FROM THROWING FOR TWO WEEKS DUE TO INFLAMED ELBOW

Bob Melvin argues call

San Diego Padres Bob Melvin argues a call during the 12th inning of a baseball game against the Philadelphia Phillies, Sunday, July 16, 2023, in Philadelphia.  (AP Photo/Matt Slocum)

"Tried to stay focused as a club, knowing today was big," Harper said. "To be able to win the series against them ... I thought we played some great baseball. I thought we hit some balls hard in those early innings, and they made some good plays. They jumped on us, then we come back, they come back, and we get to extra innings and go back and forth."

BRYCE IN THE FIELD

Phillies manager Rob Thomson said Harper likely will play his first big league game at first base this week, his first time in the field since Tommy John surgery last November. Harper has been a DH and pinch hitter since his return on May 2.

TRAINER’S ROOM

Padres: LHP Adrian Morejon was placed on the 15-day IL with right knee inflammation.

Phillies: OF Cristian Pache will have right elbow surgery to re-insert a screw from an operation prior to his career start in 2015 that has become troublesome. Thomson said the procedure will sideline Pache for "weeks, but not months."

CLICK HERE TO GET THE FOX NEWS APP

Kyle Schwarber celebrates with Alec Bohm

Philadelphia Phillies Kyle Schwarber, right, celebrates with Alec Bohm, center, and Gregory Soto after hitting a game-winning RBI-sacrifice fly against San Diego Padres relief pitcher Tim Hill during the 12th inning of a baseball game, Sunday, July 16, 2023, in Philadelphia.  (AP Photo/Matt Slocum)

UP NEXT

Phillies: RHP Aaron Nola (8-6, 4.39) starts Tuesday’s series opener against visiting Milwaukee and RHP Julio Teheran (2-3, 3.64).

Padres: RHP Joe Musgrove (8-2, 3.29 ERA) starts Tuesday’s series opener at Toronto, which pitches RHP Alek Manoah (2-7, 5.91 ERA).