The Nationals seemed on the ropes in the seventh when they were trailing 5-2 but began a comeback with a two-out RBI single from Wilson Ramos.
After Bryce Harper sacrificed to move the runners up, Gonzalez German (1-2) took the mound and surrendered an RBI groundout to Anthony Rendon, making it 5-4.
Ryan Zimmerman (3-for-5) then legged out an infield hit to score the tying run and Werth followed with a liner to center field for the key blow.
Erik Davis (1-0) notched his first major league win and Rafael Soriano earned his 36th save as Washington avoided a three-game sweep.
Matt den Decker hit his first big league homer and Lucas Duda drove in a pair of runs for the Mets.