MIAMI -- Ryan Zimmerman made up for lost time and immediately tested the injury that resulted in a lengthy absence.
"It was fun to be out there and be part of the team and be out with the guys in a really good win," Zimmerman said.
Zimmerman, who missed 55 games because of a hamstring injury, had his run-scoring triple to key Washington's three-run seventh inning. Asdrubal Cabrera's RBI triple tied the score at 2-2 and chased Miami starter Jarred Cosart, and Denard Span's single off reliever Mike Dunn put the Nationals ahead.
Washington starter Jordan Zimmermann (13-5) gave up two runs and five hits over six innings. He struck out four and stayed in the game and finished the inning despite getting hit by a line drive from Casey McGehee to start the sixth. Second baseman Cabrera retrieved the ball and threw McGehee out.
"It happened so fast," Zimmermann said. "I saw the ball coming and thought that it was stopped. I just tried turning and lift my shoulder. I was lucky enough that it hit my shoulder and not my face.
"It's a little sore -- pretty tight right now but it will be fine. It's not going to affect me."
Nationals manager Matt Williams and assistant trainer Steve Gober immediately raced to the mound to check on Zimmermann.
"He was pitching well, he could certainly go longer but not with something like that," Williams said. "We're not going to take any chances there.
"It's scary but I think he's going to come out of it fine."
Aaron Barrett and Tyler Clippard pitched perfect innings in the seventh and eighth, and Drew Storen gave up one-out singles to Marcell Ozuna and Justin Bour in the ninth before he retired pinch hitter Garrett Jones on a game-ending double play for his ninth save in 12 opportunities.
Cosart (4-3) was charged with all three runs and gave up nine hits in 6 1/3 innings. He walked two and struck out two.
"I wasn't' sharp, I wasn't down," Cosart said. "Throw a bad pitch, a lot of balls in the middle of the plate. They've won 90 games for a reason and that's what they're supposed to do with those pitches."
NL East champion Washington moved 2½ games ahead of the Los Angeles Dodgers for best record in the league.
The loss eliminated Miami from wild-card contention.
"I'm proud of these guys," Marlins manager Mike Redmond said. "We've battled through a lot of adversity -- they've given me everything they have every single day.
"Losing (right fielder Giancarlo Stanton) was a big blow -- a big blow to our team and to our offense and to our lineup."
Miami avoided a bigger inning in the seventh when Zimmerman was thrown out at home on a fielder's choice. The Nationals appealed call but the video review upheld the call that catcher Jeff Mathis tagged Zimmerman's left leg before it crossed home plate.
"The ball, when I'm on third, it was instincts and I go and I went," Zimmerman said. "I probably shouldn't have gone. Everything's fine nothing happened but looking back, it wasn't the smartest thing to do."
Bour's RBI single in the first put the Marlins on the scoreboard, and they doubled their lead in the fourth when Reed Johnson doubled to center and scored on two throwing errors on the play.
The Nationals won their 10th consecutive game in a game started by Zimmermann.
Zimmerman started in left field as Williams gave Bryce Harper the night off.
With Zimmerman expected to play many of the Nationals' remaining games in left field, Williams plans on utilizing Harper in the other outfield positions.
"Harp's got the ability to play all three," Williams said. "He may move around a little bit the next two, three games in the outfield to give Zim a chance."
There was speculation that Miami was going to shut down Eovaldi for the remainder of the season. Eovaldi, 24, has lost his last six decisions and has surrendered 26 earned runs in 35 innings during his winless stretch.
"We believe in this guy and his stuff," Redmond said. "He's pitched a lot of innings this year and whether he's getting a bit tired or whatever but that's part of being a major league starter and pitching 200 innings."