Drew Storen pitched the ninth inning for his second save of the season.
Manager Davey Johnson called the victory possibly the biggest one of the season.
"The guys battled," Johnson said. "[Mets manager] Terry [Collins] is making every move he could to try and have the edge, and guys got key base hits. That's what we are capable of. … It was a big, uplifting win."
The victory reminded Ryan Zimmerman of the 2012 Nationals. They had a lot of comeback victories. This year, those types of victories have been few and far between.
"The beginning of the year, we had no comeback wins, no runs scored late," Zimmerman said. "The past couple of weeks, we have been getting a lot better at that. That's the team we were last year. Hopefully we can continue to do that, because we are not going to get to the starter every day. Sometimes you have to come from behind. It's not easy, but good teams do that."
At first, it looked like Mets right-hander Matt Harvey was going to win his eighth game of the season. He pitched seven strong innings and allowed three hits. In fact, Harvey had a perfect game until the top of fifth inning, when Desmond hit an 0-1 pitch over the left-field wall to tie the game at 1. It was Desmond's 14th home run of the season.
"This morning when I woke, I thought he had no-hit stuff," Desmond said about Harvey. "He's always got no-hit stuff. He throws 97 miles per hour with a breaking ball, cutter, slider, changeup, everything else you got. He has it. You go out and try to play with your best foot forward. Sometimes you win, sometimes you lose."
Other than the home run, Harvey dominated, striking out 11 batters. The Nationals had a runner in scoring position only once against Harvey, and that occurred in the sixth inning. With two outs, Denard Span tripled to right field and was left on third when Anthony Rendon struck out to end the threat.
Nationals left-hander Ross Detwiler battled, lasting five innings, allowing three runs (two earned) on six hits and striking out four batters.
The Mets scored their first run in the fourth inning. After David Wright led off with double, Marlon Byrd followed and hit a ground ball to Desmond at short. Desmond's throw went past first baseman Adam LaRoche for a two-base error, allowing Wright to score and giving New York a 1-0 lead. It was Desmond's first error since April 21.
The Mets broke things open in the fifth inning against Detwiler. Eric Young Jr. scored the go-ahead run on a double by Byrd, while Byrd scored on a single by Josh Satin.
Right-hander Ross Ohlendorf was on the mound when New York scored its last run of the game in the seventh inning. Satin doubled to right-center field, scoring Daniel Murphy.
But with Harvey out the game, the Nationals tied the score at 4 in the eighth inning against New York's shaky bullpen.
"Their bullpen has been decent, but I think you would rather face -- right now -- anyone than [Harvey], because he is throwing the ball pretty well," Zimmerman said.
The Nationals took advantage of the situation. Right-hander David Aardsma managed to get two outs and was taken out of the game for left-hander Josh Edgin to face Span, who was hitting .136 against southpaws entering Friday's action. But the strategy backfired, as Span doubled to put runners on second and third.
"It's easy. You're looking at Span. He hits less than .200 against left-handers," Collins said. "Edgin's throwing the ball well, threw the ball great in Philly. He gets on base, here come the other two guys anyway. He was the out I wanted to get for sure."
In came Brandon Lyon. He, too, had problems getting that third out. He walked Rendon to load the bases before Zimmerman hit a 1-0 pitch for a double to left center field, scoring three runs.
"There is nobody else on the team, including myself, that I want in that situation other than [Zimmerman]," Desmond said. "He is a proven big league hitter. He has made a career of doing damage in situations like that. You don't get the accolades, the contract, all the other stuff, just by going up there and being a standup guy. He is obviously that. But he's an unbelievable baseball player, great hitter, our cornerstone, you could say."
With the victory, the Nationals are a game over .500 with a 40-39 record this season.
"I think the way we finished that game was the key. Everybody had good at-bats," Johnson said.