Harper, who snapped a 1-for-10 funk, also singled and walked twice as the Phillies evened their seven-game series with Miami at 2-2.
''The last couple of weeks my team has picked me up for sure,'' Harper said. ''Everybody was swinging the bats really well. I was just standing there. As an organization, as a whole, these guys have been cheering me on and wanted me to do my best.
''If we're going to be successful as an organization as a team, I have to play better. It's plain and simple.''
Didi Gregorius hit his seventh career grand slam, and Kyle Garlick keyed a five-run eighth with a bases-clearing double.
Gregorius gave the Phillies an early lead with his blast in the first. Gregorius drove a slider from Miami starter Jose Urena (0-1) over the wall in right field for his seventh homer of the season.
Harper increased Philadelphia's advantage to 5-0 with a leadoff shot in the third.
''Really encouraging because we're going to need his bat down the stretch,'' Philadelphia manager Joe Girardi said of Harper. ''When a guy that good goes through some struggles, he's going to get hot. We know he can carry a club. He hit balls hard everywhere.''
Phillies starter Spencer Howard left with right shoulder stiffness after allowing Brian Anderson's three-run homer in the fourth. The rookie right-hander had kept the Marlins hitless through the first 3 2/3 before Jesus Aguilar singled. Matt Joyce walked and Anderson followed with his sixth homer. Howard walked two and struck out five.
Heath Hembree (3-0) relieved Howard and pitched 1 1/3 scoreless innings. Adam Morgan was the Phillies fifth reliever and pitched a scoreless ninth.
Miami closed to within 6-4 on Lewis Brinson's RBI double in the sixth, but the Phillies responded with an infield single by Adam Haseley' that scored Jean Segura from third in the seventh.
''Every time we got anywhere close, it seemed like they ran on us again,'' Miami manager Don Mattingly said.
Aguilar had three hits, including his sixth homer for Miami.
Urena, who celebrated his 29th birthday Saturday, yielded six runs and five hits. He walked four and struck out two.
REALMUTO REMOVED LATE; SCARY MOMENT FOR HOSKINS:
J.T. Realmuto was removed in the ninth inning as a precaution. Girardi said Realmuto felt hip discomfort
''We'll evaluate him (Sunday) and see where's he at,'' Girardi. ''We just have to see how he is and keep our fingers crossed.''
First baseman Rhys Hoskins avoided serious injury when he attempted to catch Realmuto's errant throw on Corey Dickerson's dribbler in the seventh. The throw led toward the baseline, where Hoskins and Dickerson collided. Hoskins favored his left arm and was treated by Phillies training staff but remained in the game.
ANOTHER MAJOR LEAGUE DEBUT:
Reliever Johan Quezada pitched a scoreless ninth and became the 17th Marlin to make his major league debut this season, setting a team record. The previous mark was set in 2010.
Phillies: LHP Jose Alvarez (testicular contusion) has been throwing from 60 feet and will be re-evaluated Tuesday.
Marlins: SS Miguel Rojas jammed his right middle finger in warm-ups before the game. Rojas singled in two at bats before Jazz Chisolm pinch hit for him in the sixth.
Phillies: Zach Eflin (2-1, 4.58) will start one of the doubleheader games against Miami Sunday. The second starter will be determined after all the options have been discussed Girardi said.
Marlins: Rookie right-hander Sixto Sanchez (2-1, 1.80) is scheduled to start one of the games Sunday. Mattingly said it has not been determined yet which end. The second starter will be announced.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP-Sports
Copyright 2020 STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.