Gonzalez (16-6) went 5 2/3 innings, holding the Mets to one run on seven hits. The left-hander issued two walks and struck out three in winning his third consecutive start.
Harper drove home Jayson Werth with a run-scoring triple in the third and came home on Ryan Zimmerman's single, staking the Nationals to a 4-0 lead, then added a solo homer in the fifth for a 5-0 advantage.
Danny Espinoza provided a two-run shot for the National League East-leading Nationals, who took the rubber match of a three-game set.
The start of the game was delayed 2 1/2 hours by rain.
Mets starter Jeremy Hefner (2-5) gave up five runs on eight hits over five full innings.
Jason Bay and Kelly Shoppach drove in runs for New York.