Michael Taylor also homered and drove in two for Washington.
Doug Fister (4-6) picked up the win. allowing two runs and four hits in six innings.
Harper's first homer, a three-run shot, came off of Tom Koehler (8-7) in the fifth inning breaking a 2-all tie.
Harper then led off the eighth by smacking a first-pitch fastball from Sam Dyson deep to right field for his 29th home run of the season. It was his third multi-home run game of the season, first since hitting two against Atlanta on May 8.
Koehler pitched six innings and allowed five runs.
Ichiro Suzuki opened the scoring with an RBI double in the second for the Marlins.
The Nationals took a 2-1 lead in the fourth when Ian Desmond hit an RBI triple and scored on a sacrifice fly by Taylor.
Adeiny Hechavarria tied the game at 2 with an RBI single.
SUZUKI GETS HIT NO. 2,900
Suzuki's RBI double in the second was his 2,900th major league hit. He also singled in the fourth and is 99 shy from joining just 29 other players in the 3,000-hit club.
Nationals: RHP Stephen Strasburg (oblique strain) made his first rehab start on Wednesday with Triple-A Syracuse, pitching four innings and allowing three runs and four hits. He struck out five and walked one while throwing 44 of 64 pitches for strikes. ... RHP David Carpenter (shoulder) was placed on the 15-day disabled list on July 17. "He's OK, it's been a slowing process," Nationals manager Matt Williams said. "He's feeling better and we'll work him back as quickly as we can, keeping in mind that we need to be careful."
Nationals: RHP Max Scherzer (10-8, 2.33 ERA) will take the mound in Thursday's series finale scheduled to start at 12:10 p.m. Scherzer is looking to bounce back after allowing five runs on seven hits including a season-high three home runs in a 7-5 loss at Pittsburgh on July 24.
Marlins: RHP Dan Haren (7-6, 3.51) could be making his final start with the Marlins as he has been the subject of trade rumors before the July 31 non-waiver trade deadline. Haren is 1-1 with a 3.94 ERA in five starts in July.