Dunn's 37th homer this season, a two-run shot off Florida starter Jason Johnson, came with two outs in the top of the first.
Zimmerman hit his 29th, a solo homer, with one out in the seventh.
Mike Morse hit a two-run, pinch-hit double in the sixth for the Nationals, who won their second straight contest despite just five hits.
The winner was starter J.D. Martin (4-4).
Closer Mike MacDougal got his 15th save despite giving up Dan Uggla's ninth-inning solo homer.
Hanley Ramirez added a two-run homer for the Marlins, who also had just five hits and have lost four in a row to the Nationals.
The losing pitcher was reliever Brian Sanches (4-2).
Johnson yielded two runs and two hits in five innings with four walks and eight strikeouts.
Copyright 2009 by United Press International.