Jose Lobaton doubled among his three hits, drove in a run and scored twice for the Nationals, who took the rubber game against the Giants despite a labored four-inning outing from starter Stephen Strasburg.
Craig Stammen (4-4) allowed a run in two innings of relief for NL-East leading Washington, which has won 12 of 13. Danny Espinosa also homered for the Nationals.
Giants reliever Jeremy Affeldt (3-2) allowed five hits and five runs in the sixth without retiring a batter after the departure of starter Ryan Vogelsong.
The Nationals' scored six runs in the sixth on eight hits, tying for their most hits in an inning since they began playing in D.C. in 2005.
Gregor Blanco and Travis Ishikawa homered for the Giants, who ended their road trip 3-3.
Brandon Crawford had three singles for San Francisco, which used its bullpen for 11 2-3 innings across the three-game series.
Strasburg allowed five earned runs — his most at home since the final game of his innings-limit-shortened 2012 season — on eight hits and two walks. His day ended by getting pinch-hitter Nate Schierholtz to pop out to short to end the fourth.
Vogelsong allowed three runs and three hits and allowed a season high-tying four walks in 5 1-3 innings. He departed with a 6-3 lead after yielding Desmond's homer.
Harper doubled and scored on Affeldt's wild pitch. Lobaton singled in Asdrubal Cabrera and Scott Hairston's pinch-hit, RBI double tied it.
Jean Machi picked Denard Span off first after entering with the game tied and runners on the corners. But Jayson Werth and LaRoche each had RBI singles to finish the scoring in the sixth.
The Nationals added a run in the seventh and five more in the eighth.
Giants: CF Angel Pagan (left calf tightness), was left out of the starting lineup for the second straight day. Pagan spent almost two months on the disabled list with a strained back before returning to the club on Aug. 7.
Nationals: OF Steve Souza Jr. (right shoulder strain) entered Sunday with two hits and an RBI in five at-bats during two rehab games at Class-A affiliates, one each with Hagerstown and Potomac.
Giants: RHP Jake Peavy (2-3, 3.58) looks for his third straight victory Monday night as San Francisco begins a seven-game homestand with the first of four against the Colorado Rockies.
Nationals: RHP Tanner Roark (12-7, 2.80) will start the first of three games at Philadelphia against A.J. Burnett (6-14, 4.42), who is 10-5 with a 3.39 ERA against Washington over his career.