Philadelphia had lost three in a row while the Twins had won seven out of nine.
The Phillies appeared on their way to an easy win after Jim Thome delivered a two-run single in the first and Mayberry soon followed with his blast to left.
Minnesota starter P.J. Walters (2-2) threw only 15 pitches in the first inning before leaving with shoulder stiffness.
Philadelphia had a 9-4 lead heading into the seventh, but the Twins scored four times on four hits in that inning and had the tying run on third when Ryan Doumit struck out to end the comeback bid.
Cole Hamels (9-3) got the win, although he left in the seventh without retiring a batter and gave up six earned runs on eight hits.
Jonathan Papelbon recorded the final four outs for his 17th save.
Swim Week Miami Beach 2014 [PHOTOS]