Lannan (7-7), who walked none, had his first-ever shutout and his second complete game of the season.
Adam Dunn was 2-for-4 with an RBI and a run scored for the Nationals, who won for the first time in six games under new Manager Jim Riggleman, who replaced Manny Acta during the All-Star break. Josh Willingham, Alberto Gonzalez and Wil Nieves each had an RBI for Washington, which ended a six-game losing streak.
Losing pitcher Oliver Perez (2-3) allowed four runs on four hits with six walks.
Jeff Francoeur had two hits for the Mets.