Detroit snapped a two-game skid and won for the 40th time this season thanks to a sudden comeback put together against Boston's Andrew Bailey (3-1).
Victor Martinez drew a leadoff walk in the ninth and Peralta promptly launched a 1-2 pitch over the wall in left to end the game.
Torii Hunter lifted Detroit into a 2-2 tie in the fifth with a two-run single, but Boston regained the lead in the eighth when David Ortiz singled in Dustin Pedroia. Ortiz also hit a solo homer in the fourth, his 15th of the season.
The ninth-inning rally gave the win to Drew Smyly (3-0), who allowed up one hit and struck out four over the final two innings.
Celebrity Couples of 2014 [PHOTOS]