Tampa Bay starter Jeremy Hellickson struggled with his control and did not survive the fifth inning, but four relievers combined to give up just two hits and a walk over the final 4 2/3 innings.
Tampa Bay has won back-to-back games to take over the lead in the American League East. Miami has dropped four straight.
Hellickson gave up his seventh walk to put runners on first and second with one out in the fifth and that finished his night.
Badenhop came on and immediately got John Buck to ground into a double play. Badenhop (1-1) also worked the sixth and was credited with the win.
An infield single by Will Rhymes drove in Jose Lobaton with the go-ahead run in the fourth and Matt Joyce gave the Rays a 3-1 lead with a solo homer in the fifth.
Miami starter Ricky Nolasco (6-4) took the loss after giving up three runs on six hits in six innings. He struck out six.