With the score tied 4-4, Burke Badenhop (0-4) walked Desmond to lead off the eighth. Cristian Guzman bunted for a hit and both runners moved up a base on first baseman Gaby Sanchez's error. One out later, Ryan Zimmerman was intentionally walked to load the bases.
Renyel Pinto relieved Badenhop and hit Dunn with a pitch, forcing Desmond home with the go-ahead run.
Matt Capps preserved the Nationals' lead, working a scoreless ninth for his MLB-best 12th save of the season. The win went to Tyler Clippard (5-0) despite allowing a run in 1 1/3 innings of relief.
Josh Willingham and Willie Harris both went deep as the Nats won their third in five games.
Sanchez got a two-run homer for the Marlins, losers of four of their last five.