Pinch-hitter Mike Morse broke a tie in the sixth inning with a two-out, two-run double for the Nationals, who had lost their six previous games at Florida this year. Mike MacDougal got the final five outs, completing a five-hitter for his 15th save in 16 chances.
The Marlins, clinging to slim playoff chances, have lost only two of their past nine games — both to last-place Washington.
Dunn hit a two-run homer in the first inning, his 37th. Zimmerman hit his 29th homer in the seventh.
NL batting leader Hanley Ramirez walked three times after hitting a first-inning two-run homer, his 23rd. Those were the only runs off J.D. Martin (4-4), who went five innings.
The Nationals led 5-2 when MacDougal came on with runners at the corners and one out in the eighth. He needed only one pitch to end the inning on John Baker's double-play grounder.
Dan Uggla hit his 28th homer for the Marlins to start the ninth. Cody Ross followed with a single and Ross Gload walked, but MacDougal struck out Emilio Bonifacio and retired Chris Coghlan on a double-play grounder.
The Marlins went 0-for-8 with runners in scoring position.
Florida ace Josh Johnson failed in a bid for his 15th win, pitching only five innings for the second game in a row and departing for a pinch-hitter with the score 2-all. The Marlins want to avoid overworking the right-hander, who has pitched a career-high 188 1-3 innings after returning from reconstructive elbow surgery in July 2008.
Johnson struck out eight, walked four, allowed two hits and threw 89 pitches.
Brian Sanches (4-2) relieved Johnson and walked Josh Willingham to start the sixth. Will Nieves singled with two out, and Morse drove in both runners.
Willie Harris led off the game with a walk, and Dunn's homer gave Washington a brief 2-0 lead. Dunn is batting .345 against Florida this year with five homers.
Nick Johnson walked and Ramirez homered in the bottom of the first to tie the game.
Florida's Andrew Miller pitched one inning in his first appearance since July 17 and gave up Zimmerman's homer.
Notes: RHP Chris Volstad will rejoin the Florida rotation and start Sunday. In his past two starts, he has allowed 10 earned runs in 5 2-3 innings. ... Nationals SS Ian Desmond spent the night on the bench after hitting a homer and driving in four runs in his major-league debut Thursday. Manager Jim Riggleman said Desmond may see playing time at 2B and in the OF before the season ends. ... SS Ramirez has gone a career-best 55 consecutive games without an error.