Scott Hairston hit a solo homer in the top of the 12th to give New York a 6-5 lead.
Michael Morse led off with his second double of the game, and Ian Desmond followed with another double for his third RBI.
Reliever Elvin Ramirez (0-1) walked two batters to load the bases, and a fielder's choice by Xavier Nady left the bases loaded with two outs for Harper, who lined an 0-2 pitch to left field. The ball fell just in front of a diving Vinny Rottino.
The Nationals are alone atop the National League East, a game ahead of Miami — which lost to Atlanta.
Both managers emptied their bullpens as the game wore on. Ross Detwiler (4-3) came on in the 11th and was the Nationals' eighth. Ramirez, the Mets' sixth pitcher, was making his second major league appearance.
In the 10th, both teams took advantage of miscues to score. Hairston led off with a single and later scored on a wild pitch by Henry Rodriguez — his ninth in 21 innings this season — to give the Mets a 5-4 lead.
The Nationals tied it in the bottom of the inning, thanks to two errors by shortstop Jordany Valdespin and a wild pitch by Bobby Parnell.
Ryan Zimmerman reached on one of Valdespin's errors, later took third on the wild pitch and scored on another error when Ian Desmond's grounder bounced off his glove. The Nationals loaded the bases with two outs in the inning, but Rick Ankiel struck out swinging.
The Mets fell behind 3-0 after five innings and started their comeback with solo home runs by David Wright and Valdespin in the sixth. Andres Torres hit a two-run double in the eighth to give New York a 4-3 lead.
Desmond tied the game at 4 with a run-scoring single in the eighth to set up extra innings.
Lost in the late-inning back-and-forth was the strong effort from Washington starter Jordan Zimmermann, who has pitched at least six innings in each of his 11 starts this season. Zimmermann held the Mets scoreless through five before giving up the pair of homers. He allowed five hits, struck out five, walked none and also had a single and double at the plate.
Chris Young gave up three runs — two earned — over five innings in his first major league start since May 1, 2011. He missed most of last year because of right shoulder surgery and pitched this year in the minors. New York purchased his contract from Triple-A Buffalo before the game.
Young didn't allow a baserunner over the first two innings, but Harper's two-out, opposite-field single in the third gave Washington a 1-0 lead.
The Nationals scored two more in the fifth on a single by Zimmerman and a throwing error by shortstop Omar Quintanilla that allowed another run to score on the play.
Valdespin led off the sixth with a pinch-hit home run into the Nationals' bullpen in right field. It was the rookie's second pinch-hit homer this season. Wright added another solo homer with two outs, barely clearing the wall in left-center field. It was Wright's 736th career run scored, setting a Mets franchise record.
NOTES: New York RHP Jon Rauch has "debris" in his right elbow, according to manager Terry Collins. He'll miss the three games in Washington, but will be available for Friday's game against the Yankees, Collins said. ... The Mets activated RHP Miguel Batista (lower back strain) from the 15-day DL and placed RHP Ramon Ramirez (strained right hamstring) on the 15-day DL. Ramirez injured the hamstring running in from the bullpen to join in the celebration of Johan Santana's no-hitter on Friday, Collins said. The Mets also designated right-handed pitcher Jack Egbert for assignment. ... Washington RHP Brad Lidge (sports hernia) made his first rehab appearance for Class A Potomac Monday and expects to have two more today and Friday.