Chris Marrero knocked in two runs and Chien- 3, to avoid a three-game sweep.
Wang (3-3) allowed three runs on six hits to record his first victory since August 16. He struck out five and did not issue a walk.
"I thought he was brilliant," said Marlins manager Jack McKeon.
Drew Storen tossed a scoreless ninth to record his 38th save of the season.
Brad Hand (1-8) surrendered four runs -- three earned -- over four innings to suffer his fifth consecutive loss.
"I felt pretty well out there tonight," said Hand. "I was throwing strikes, just a few bad pitches at a few costly times."
The Nationals wasted a Ryan Zimmerman two-out double in the first, but took a 1-0 lead in the second when Jonny Gomes led off with a two-bagger, advanced to third on a groundout and scored on Marrero's sac fly.
Wang allowed just one hit -- a single from Hand -- through four frames and the Nationals rewarded him with three runs in the home half.
Zimmerman and Michael Morse began the frame with a double and a walk, respectively. Two batter later, Danny Espinosa singled up the middle. The ball rolled under the glove of center fielder Bryan Petersen, allowing Zimmerman and Morse to score and Espinosa to reach third. Marrero's subsequent ground-rule double made it a 4-0 game.
"He's just consistent," Gomes said of Marrero. "He doesn't look overmatched."
A half-inning later, Sanchez led off with his 19th homer of the season to put the Marlins on the board.
In the seventh, Petersen singled with one down and Hayes followed two batters later with his fourth homer of the season to pull the Marlins within a run and drive Wang from the game.
Tyler Clippard entered and retired Vinny Rottino to end the inning, then tossed a 1-2-3 eighth. Storen was perfect in the ninth to seal the Nationals sixth victory in their past eight games.
With their 42nd home win, the Nationals set a single-season club record for home victories...The Marlins had won five straight games over the Nationals...Hand hasn't won since July 7.