Bryce Harper hit his 27th home run and Freddy Galvis also connected for the playoff-chasing Phillies.
Herrera had been 0 for 4 in the game before driving in automatic runner Freddy Galvis from second.
Ian Kennedy (1-0) pitched two scoreless and struck out four. Dylan Floro (5-6) took the loss.
Miami tied it at 3 with an unearned run in the sixth inning. Jazz Chisholm Jr. reached on an error by first baseman Brad Miller and later scored on Bryan De La Cruz’s grounder.
After managing only one walk in the first three innings against Miami starter Elieser Hernandez, the Phillies’ broke loose in the fourth. Harper homered, and Galvis hit a two-run drive for a 3-1 lead.
Harper, who enjoyed a surge at the plate in August, began the day with only a single in eight at-bats in the first two games of the series.
De La Cruz recovered nicely after being hit by a pitch in his first at-bat, connecting for a solo homer in the fourth.
Miami took an early lead against Sam Coonrod, a reliever went 1 1/3 innings in his first major league start, on a bases-loaded grounder by Isan Diaz in the second inning.
Philadelphia missed a chance to add to its lead in the sixth after J.T. Realmuto greeted reliever Zach Thompson with a double. The former Marlins catcher advanced to third on a sacrifice bunt by Harper — his third in the last seven seasons — but was left stranded.
Harper continues to be a nemesis to the Marlins. In 152 games against Miami with both Philadelphia and Washington, Harper has 33 home runs and 101 RBIs.
De La Cruz was hit high, behind his left shoulder, by a 98 mph fastball from Coonrod in the second. De La Cruz immediately fell to the ground, grabbing the back of his head in pain, and remained motionless for several minutes. He stayed in the game and managed a smile while standing on first base.
RHP Zack Wheeler (11-9, 3.01) gets the start for the Phillies in their series opener at Milwaukee. The Marlins will go with RHP Edward Cabrera (0-1, 5.23) to begin a three-game set against the Mets.