In his fourth at-bat he produced an RBI groundout. He finished the game 3-for-4 with five RBIs.
Harper hit a 393-foot solo shot leading off the second inning, a 442-foot, two-run drive in the third and a 445-foot bases-empty shot in the fifth, the last two reaching the second deck. Each of the home runs came on the second pitch of the at-bat off Tom Koehler (2-3).
Harper connected in the fifth inning with such force that Marlins outfielder Giancarlo Stanton stood motionless in right field, looking toward the infield as the ball soared into the seats behind him.
"That's how I should be. Plain and simple," Harper said of his big day. "That's how I expect myself to play. Of course you're not going to do that every single day. You're not going to go out there and hit three homers, drive in five. But that's the type of player I need to be."
Harper entered the game 1-for-17 in May and 2-for-15 against Koehler, although one of those hits was a home run.
"I made three mistakes against him and he hit the ball hard three times," Koehler said. "Fastball away that stayed up, fastball in that was up and came back over the plate and a slider that just kind of spun up there."
The 22-year-old slugger now has eight home runs this season.
Harper, in his fourth major league season, previously hit two homers in a game on five occasions, but admitted he was hoping to become the first Nationals player to ever hit four home runs in a game.
"Going up there against [reliever Sam] Dyson, runner on third base, you're trying to get that run in," Harper said. "Of course you want to try to get that fourth homer. That's something that would've been very cool to get."
The Associated Press contributed to this report.