BOSTON — What was once a tough Tuesday night for J.D. Martinez turned into a glorious one.

The slugger mashed a two-run, walk-off double with two outs in the bottom of the 12th to give the Red Sox a thrilling 6-5 victory in 12 innings.

Martinez had a chance to end the festivities in the 10th when he just needed a sacrifice fly to drive in the walk-off run, but he grounded to short.

And in the eighth, Martinez lost track of how many outs there were and was doubled off to end the frame on a lineout to deep center by Rafael Devers.

In baseball, however, there so often seems to be a chance for redemption.

Martinez, who has come out swinging a red-hot bat this season after a 2020 that he’d like to forget, seized that moment.

The only question was whether Martinez got enough of the 1-1 pitch from Rays reliever Ryan Thompson to get it over the head of right fielder Randy Arozarena.

It seemed like Arozarena took a bit of a circuitous route on the 99.6 mph shot by Martinez, which had an expected batting average of .580.

Arozarena face-planted as the ball soared over him, and the Red Sox mobbed their walk-off hero between second and third base.

“I don’t know. You never know,” said Martinez, when asked if he thought his game-winner was going to be caught. “It’s Fenway in the winter. I feel like you never know if the ball is going to go or not. It was just enough I feel like. I think he had to play it exactly how he played it. Winning run is on second base. He’s got to shade in on that. That’s pretty much the only ball that could beat him there.”

And with that satisfying ending, Martinez no longer had to beat up himself.

After the baserunning snafu, Christian Vázquez made Martinez feel better when he hammered a game-tying homer to lead off the bottom of the ninth.

“Yeah I told him, ‘Christian, that was just planned, dude, because I knew you were going to take [Diego] Castillo deep’”, Martinez said. “And he was like, ‘Yeah, good job, good job.’”

But there would be more frustration for Martinez in the 10th.

When automatic baserunner Kiké Hernández advanced to third with one out on a groundout by Christian Arroyo, Rays manager Kevin Cash walked Alex Verdugo and put the game in Martinez’s hands.

All the master of the launch angle needed was a sacrifice fly to end the game right there. Instead, Martinez ripped a grounder that shortstop Willy Adames — who was playing in — made a nice play on, and there was no advancement.

The teams traded runs in the 11th, and the Rays once again scored in the top of the 12th.

With two on and two outs, the game came down to Martinez.

“All jokes aside, after I made that mental mistake on second and then coming up with the go-ahead run on third in the [10th] and hitting that ball, Adames made a great play on it, but not winning it there, it felt good to come through there in that situation,” Martinez said.

For the Red Sox, who were swept in three straight by the Orioles to start the season, this win was a big deal, especially considering the opponent.

After regrouping by thumping the Rays, 11-2 on Monday, the Red Sox trailed 3-1 on Tuesday when overpowering Rays ace Tyler Glasnow left the game after six dominant innings.

But they whittled away and got into a tug-of-war, before finally pulling through in the end.

“We didn’t stop playing and that’s the mark of a good team. It didn’t look great at one point, but we kept fighting, we kept them within [striking] distance, the pitching staff did an amazing job, and we made some plays,” manager Alex Cora said. “I don’t remember every play of the game, but we kept fighting, we were down to one pitch [from losing], we get a hit by pitch, then there’s a wild pitch, and J.D. put a good swing on it. We won the series against the defending American League champions.”

The Kansas City Chiefs are 2019 NFC Champs - get your gear on at Fanatics