The Phillies overcame a three-run deficit to tie the game in the sixth, again fell behind by a run and then got a solo homer from Erik Kratz in the ninth to force extra innings.
Kevin Frandsen opened the Philadelphia 10th with a single off Cristhian Martinez (5-4), went to second on a balk and reached third on a ground out.
Mayberry, however, hit the first pitch he saw over the wall in left.
Jonathan Papelbon retired the side in the bottom of the 10th to collect his 31st save and preserve the win for Josh Lindblom (3-3).
Lindblom, the fifth of six Philadelphia pitchers, worked the ninth inning.
Atlanta lost its second straight and fell 6 1/2 games behind Washington in the National League East.
Celebrity Breakups and divorces of 2014 [PHOTOS]