After pinch hitter John Jaso reached base on an error by second baseman Dee Gordon, Cabrera took a 2-0 offering from Marlins reliever Bryan Morris and sent it into the right-field bleachers.
"In that situation, 2-0 count, I'm trying to hit the ball hard," Cabrera said. "That felt so good too. We have to finish the season, play hard for the fans who come to watch the game. We've got to try to give the win to them."
The Marlins tied the game at 2-2 in the top of the eighth inning when a single from third baseman Martin Prado scored center fielder Christian Yelich. The run took a win away from Moore, despite having another quality start.
Moore gave up one run and seven hits while striking out three over seven innings.
"I'm very grateful to be back and pitching pain-free with the stuff that's coming out right now," Moore said. "It does feel good to roll out of a couple (quality starts) in a row, regardless of what the overall situation is."
Alex Colome (7-5), gave up the game-tying hit, but struck out two in two-thirds of an inning to get the win and Brad Boxberger pitched a perfect ninth to earn his 39th save of the season.
Good win, I think Matt Moore obviously set the tone," Rays manager Kevin Cash said. "He's been really good lately. The work that he's put in and to consistently go out there and continue to do that. It's very exciting for all of us in this building. I think you can lump him in with Drew Smyly, getting back and showing that they're healthy and also pitching really well on top of that."
Morris (5-4) gave up a hit and one earned run in the loss.
The Rays took a 2-1 lead the fourth inning after loading the bases with one out. Center fielder Kevin Kiermaier hit a sacrifice fly to center that scored Cabrera.
The Marlins took a 1-0 lead when Rays starter Matt Moore gave up back-to-back doubles to Gordon and Yelich to open the game.
Moore settled down and retired the next 10 of the next 11 batters he faced.
Tampa Bay tied the game at 1-1 in the third inning when right fielder Mikie Mahtook hit his seventh home run of the season, a solo shot in left field off Marlins starter Adam Conley.
"Home runs and double plays spoiled the deal," Marlins manager Dan Jennings said. "Conley, another excellent start. Gave us a shot, thought he used his fastball very well. The home run that he gave up to Mahtook was actually a good pitch. The kid went down and got the ball, just a good piece of hitting on a ball that was really a pitcher's pitch."
Conley gave up two runs on five hits in six innings. He threw 97 pitches (60 strikes) and struck out five.
"I'm happy about the way I threw with what I had today," Conley said. "Just didn't feel like the ball had the life on it today that I've had in the past. It's tough to get beat, it's tough to give up runs to guys you gave free passes to."
NOTES: Rays 2B Logan Forsythe exited the game in the third inning due to a bruised right foot. He was hurt when hit by a pitch in the first inning. ... Rays manager Kevin Cash said he was not sure if LHP Matt Moore would get another start this season after Tuesday. Cash said he hadn't set the rotation for the final weekend series against the Toronto Blue Jays. ... Marlins RF Giancarlo Stanton was not with the team, and manager Dan Jennings confirmed that the slugger's season is over. Stanton broke the hamate bone in his left hand on June 26. ... Rays OF Brandon Guyer was hit by a pitch 21 times this year, tops in the American League through Monday. ... Marlins 2B Dee Gordon is the first National League player with at least 190 hits and at least 50 stolen bases in a season since Jose Reyes did it with the New York Mets in 2008.