With the score tied 2-2 in the sixth, Mayberry led off by belting a pitch from Nationals starter Gio Gonzalez (16-7) into the first row of the left field bleachers, putting the Phillies ahead to stay.
Philadelphia added an insurance run in the eighth when Chase Utley was hit by a pitch, stole second and third base, and scored on Mayberry's sacrifice fly.
Roy Halladay (8-7) earned the victory, holding the Nationals to two runs on seven hits through seven frames. The right-hander walked one and struck out six.
Jonathan Papelbon tossed a 1-2-3 ninth to rack up his 29th save as Philadelphia clinched its three-game set.
Gonzalez ended up allowing three runs on five hits through six innings.
Steve Lombardozzi supplied a two-run single for National League East-leading Washington.