Christian Vazquez belted the game-winning two-run home run in the bottom of the 13th as Boston moved to within one game of the ALCS.
Nick Pivetta took the win after a sterling relief outing while Luis Patino suffered the loss.
Red Sox walk-off after controversial play in top of the 13th
Tampa Bay jumped out quickly against Eovaldi as Wander Franco singled and Austin Meadows sent the first pitch over the right field fence to give the Rays a 2-0 lead.
Kyle Schwarber responded in the bottom of the first with a solo shot off of Drew Rasmussen to cut the lead in half. The game was tied in the bottom of the third after three straight singles, Hernandez with the RBI.
Rafael Devers put the Red Sox ahead with a single off Josh Fleming to make it 3-2 Boston. Joey Wendle doubled with one out in the fifth, but Eovaldi stranded him to preserve the Boston lead.
Hernandez doubled the lead with a solo home run off of Pete Fairbanks, reaching base for a seventh straight time, a franchise record. A walk and wild pitch gave Boston a chance to extend their lead, but Fairbanks got out of trouble.
Red Sox manager Alex Cora opted to go to Hansel Robles rather than Garrett Whitlock and Franco greeted him with a home run. With two outs, Randy Arozarena doubled to center to tie the game. Whitlock did come in and he struck out Mike Zunino to eventually end the inning.
Pivetta entered the game in the 10th and provided Boston with four sensational innings of scoreless relief, striking out seven.
The Red Sox had a chance to win it in the 11th when Christian Arroyo doubled, but David Robertson struck out Bobby Dalbec and Hernandez grounded out to end the inning.
Controversy cost Tampa Bay in the 13th as Kevin Kiermaier hit a ball out to right, bounced off the wall, hit Hunter Renfroe and over the wall for a ground-rule double, Diaz being sent back to third after he had originally scored. Pivetta struck out Zunino to end the inning.
In the bottom of the inning against Patino, Renfroe drew a one-out walk and Vazquez sent everyone home by launching one into the Monster Seats to end a game that will long be remembered.
Game 4 preview
Boston will look to book their spot in the American League Championship Series when they send Eduardo Rodriguez to the mound while Tampa Bay will counter with Collin McHugh.
Fox Sports 1 will have the action with Joe Davis as the play-by-play man, John Smoltz as the color analyst and Ken Rosenthal serving as on-field reporter. First pitch is at 7:07pm.