Austin Hedges had four hits, including a tiebreaking homer in the seventh, and Joey Lucchesi pitched six strong innings to lead the San Diego Padres to a 3-2 victory over the Philadelphia Phillies on Sunday.

Luis Urías also went deep for the Padres, who had lost seven consecutive rubber games before taking two of three in Philadelphia.

Phillies outfielder Bryce Harper left after the fifth inning because of dehydration.

San Diego Padres' Joey Lucchesi pitches during the second inning of a baseball game against the Philadelphia Phillies, Sunday, Aug. 18, 2019, in Philadelphia. (AP PhotoMatt Rourke)

San Diego Padres' Joey Lucchesi pitches during the second inning of a baseball game against the Philadelphia Phillies, Sunday, Aug. 18, 2019, in Philadelphia. (AP PhotoMatt Rourke)

On a hot, muggy afternoon with a gametime temperature of 90 degrees, Harper was lifted prior to taking the field in the sixth. Harper, who signed a 13-year, $330 million contract in the offseason, has played in 123 of 124 games this season.

Harper singled in the fourth inning, pulling up abruptly after rounding first base while considering trying for a double. He later slid hard into second base while breaking up a potential double play.

Harper also made a strong throw in the top of the fourth, nailing Hedges at second base as he tried to stretch a single into a double.

San Diego Padres' Josh Naylor, right, avoids a collision with Manuel Margot as he catches a hit off of Philadelphia Phillies' Scott Kingery in the second inning of a baseball game Sunday, Aug. 18, 2019, in Philadelphia. (AP PhotoMatt Rourke)

San Diego Padres' Josh Naylor, right, avoids a collision with Manuel Margot as he catches a hit off of Philadelphia Phillies' Scott Kingery in the second inning of a baseball game Sunday, Aug. 18, 2019, in Philadelphia. (AP PhotoMatt Rourke)

Lucchesi (8-7) gave up two runs on three hits with four strikeouts and two walks, halting his second-half struggles. Lucchesi entered 0-3 with a 6.15 ERA in six starts since the All-Star break, and San Diego had lost all six of those games. But he kept the Phillies off-balance with a fastball that tops out in the low 90's and a slow, sinking changeup.

Jean Segura had a pair of RBI doubles for the Phillies, who lost their second straight after tying their season high with four consecutive wins. Philadelphia entered Sunday a game behind the Cubs for the NL's second wild-card berth.

Hedges belted an 0-2, 78-mph curveball from Jared Hughes (3-5) over the wall in left with one out in the seventh to put San Diego up a run. His other three hits were singles.

Philadelphia Phillies' Jean Segura (2) tags out San Diego Padres' Luis Urias during the second inning of a baseball game, Sunday, Aug. 18, 2019, in Philadelphia. (AP PhotoMatt Rourke)

Philadelphia Phillies' Jean Segura (2) tags out San Diego Padres' Luis Urias during the second inning of a baseball game, Sunday, Aug. 18, 2019, in Philadelphia. (AP PhotoMatt Rourke)

Kirby Yates struck out the side in a perfect ninth for his NL-leading 35th save in his 38th chance.

The Phillies had tied it in the sixth on Segura's two-out double to left-center that scored Adam Haseley, who walked after replacing Harper in the batting order.

Jason Vargas, in his fourth start since being acquired from the Mets, allowed two runs on six hits with four strikeouts and two walks in 5 2/3 innings. The 36-year-old Vargas has a 3.91 ERA with Philadelphia.

Philadelphia Phillies' Jason Vargas pitches during the first inning of a baseball game against the San Diego Padres, Sunday, Aug. 18, 2019, in Philadelphia. (AP PhotoMatt Rourke)

Philadelphia Phillies' Jason Vargas pitches during the first inning of a baseball game against the San Diego Padres, Sunday, Aug. 18, 2019, in Philadelphia. (AP PhotoMatt Rourke)

Philadelphia went ahead in the first on the first of Segura's two-out RBI doubles, this one scoring Harper.

San Diego took the lead with a pair of runs in the fourth on Urías' opposite-field shot to right field that made it 2-1. It was the second home run of the season and fourth in 143 career at-bats for Urías.

Rhys Hoskins nearly tied it in the eighth, but his drive to deep center was caught at the wall by Manuel Margot. Hoskins went 0-for-4 and has one hit in his last 17 at-bats.

TRAINER'S ROOM

Padres: Josh Naylor called out the trainer during his at-bat in the eighth inning and appeared to be flexing his right side after swinging through a 1-1 pitch. After popping out to short, Naylor was replaced in left field by Travis Jankowski.

UP NEXT

Padres: San Diego opens a three-game set at Cincinnati on Monday night with LHP Eric Lauer (6-8, 4.55 ERA) opposing Reds RHP Trevor Bauer (10-9, 4.12).

Phillies: After an off day on Monday, the Phillies begin a two-game series at Boston on Tuesday with ace RHP Aaron Nola (11-3, 3.56) on the mound for Philadelphia. The Red Sox haven't announced their starter.

More AP MLB: https://apnews.com/MLB and https://twitter.com/AP_Sports