Despite winning 11 of 13 in a belated run, the Nationals trail Cincinnati by five games for the final NL wild-card slot with nine games remaining.
Denard Span went 0 for 4 for Washington, ending his hitting streak at 29 games - one short of the Nationals record. He was bidding to become the 27th player to have a 30-game hitting streak since Joe DiMaggio had his 56-game run in 1941.
Span received a standing ovation from many in the crowd of 25,945 after he struck out in the seventh, his final at-bat.
Gonzalez (11-7) allowed two runs and seven hits over six innings to improve to 3-0 against Miami this season. He struck out three, lifting his team-high total to 186.
Drew Storen and Tyler Clippard each worked a scoreless inning before Rafael Soriano got three outs for his 42nd save.
Harper’s 20th homer of the season came in the first inning off Henderson Alvarez (4-5) and turned out to be all the offense the Nationals needed to improve to 12-4 against Miami, including 7-0 at home.
Ed Lucas had three hits for the Marlins, who must go 7-2 in their last nine games to avoid 100 losses.
Miami went up 1-0 when Donovan Solano opened the game with a double and Lucas followed with an RBI single.
In the bottom half, Ryan Zimmerman hit the first of his three singles and Jayson Werth walked before Harper drove a hanging curveball over the wall in center field. It was his first home run since Aug. 29.
The Marlins loaded the bases with two outs in the third before Placido Polanco flied out.
Successive doubles by Giancarlo Stanton and Justin Ruggiano got Miami within 3-2 in the sixth, but Gonzalez nabbed Ruggiano trying to steal third, short-circuiting the uprising.
NOTES: Jordan Zimmermann seeks his 19th win for Washington on Friday night. Miami starter Jacob Turner (3-7) will attempt to break a six-game losing streak. ... The Nationals acquired minor league pitcher Matthew Spann as the player to be named in the Aug. 23 trade that sent OF David DeJesus to Tampa Bay. Spann is 14-10 with a 3.03 ERA in four pro seasons. ... Washington manager Davey Johnson expects RHP Stephen Strasburg to start Saturday. Strasburg felt forearm tightness while throwing Wednesday and was scratched from his scheduled start Thursday. ... Both teams received a warning from home plate umpire Bill Welke after Alvarez hit Ian Desmond with a 3-0 pitch in the first inning. ... The Nationals are 28-11 since Aug. 8.