PHILADELPHIA (AP) -- Giancarlo Stanton launched his major league-leading 47th home run, J.T. Realmuto hit an inside-the-park homer and the Miami Marlins overcame a five-run deficit to beat the Philadelphia Phillies 9-8 on Thursday.
Stanton led off the third inning with his 14th homer in August, extending his club record for most in one month. He now has seven home runs against the Phillies this season, his most against any one team.
Realmuto tied it at 8 in the sixth inning with a two-run shot, which ricocheted off the wall in left-center and past center fielder Nick Williams.
Realmuto put the Marlins ahead in the eighth with a sacrifice fly off Luis Garcia (1-4).
A.J. Ellis and Christian Yelich also homered for Miami. Rookie Rhys Hoskins and Tommy Joseph homered early as Philadelphia took an 8-3 lead.
Jarlin Garcia (1-2) won in relief and Brad Ziegler picked up his eighth save.
The Marlins moved back to .500 at 63-63 after winning three times in the four-game series. The Phillies dropped to 46-80, the worst record in baseball.
Hoskins led off the second with his eighth home run and added a two-run single in the third. Joseph followed with a three-run homer to cap a five-run inning.
Williams knocked in two with a two-out double an inning later.
Marlins starter Vance Worley allowed all eight runs on nine hits. He had given up just nine runs in his last five starts.
Five Marlins relievers each threw a scoreless inning to keep their team in the game.
Down 8-3, the Marlins fought back with a trio of home runs. Ellis hit a two-run shot off starter Jake Thompson, who allowed five runs in just five innings.
Yelich hit a solo homer off Jesen Therrien and two batters later, Realmuto tied it.
Hoskins became just the third major leaguer to hit eight home runs in his first 15 games. He joined Carlos Delgado and Trevor Story to reach that feat.
To make room for Thompson on the 25-man roster, the Phillies optioned RHP Ricardo Pinto to Triple-A Lehigh Valley.
Marlins: LHP Adam Conley (6-5, 4.93) opens a three-game set in Miami against the San Diego Padres, who have LHP Travis Wood (3-4, 5.81) scheduled to pitch.
Phillies: RHP Jerad Eickhoff (3-7, 4.46 ERA) starts with an extra day of rest on Friday against the Chicago Cubs. LHP Jose Quintana (8-10, 4.27 ERA) faces the Phillies for the first time since 2013.