The Mets welcomed back Edwin Diaz from the injured list in the ninth inning on Thursday night at Citi Field. Light show, trumpets, the whole shebang.

But the Mets were down a run to the Marlins. Diaz threw his first pitch to the backstop before retiring the Marlins in order with a strikeout.

The problem was the Mets had been no-hit for the first 5 1/3 innings by rookie righthander Roddery Munoz and had two hits going into the ninth.

It turns out the Mets only needed three.

J.D. Martinez earned his own light show and then a Gatorade shower when he hit a two-run, walk-off home run to right-centerfield with one out to give the Mets a 3-2 victory before 22,485.

The winning pitcher? Diaz.

The team with the most walkoff wins in the majors? The Mets, with six.

 

It was the first walk-off homer of Martinez’s 14-year, 1,563-game career. The 36-year-old has 321 home runs.

“Everyone always jokes about that with me,” Martinez said. “My friends and family and stuff. No I’m going to get in my chat here and talk some crap.”

The Mets (30-37) have won eight of 12. The victory moved them to within three games of the final NL wild-card spot.

Martinez chalked up the Mets’ recent improvement to the May 29 players-only meeting after they were swept by the Dodgers.

“I think we kind of said, ‘You know what? No one’s expecting us to do anything anymore,’ ” Martinez said. “ ‘ Let's just go out there and enjoy it and have fun. We're going to lose, we’re going to lose. We’re going to win, we’re going to win. Let's just keep the mood up. Let’s take the pressure off of us because we don’t have any pressure right now.’ Kind of just going back to that meeting — it was one of the better meetings I feel like I've ever been in in my career. I've been in a lot of meetings where you kind of leave and it's just, ‘We’ve got to be better at this, this and that.’ But it was one of those meetings where you left and everyone was positive and excited to come back to the field.”

Francisco Lindor led off the ninth with a walk against Miami closer Tanner Scott (5-5). Scott struck out Brandon Nimmo, who went 0-for-3 with a walk and is down to .215.

Lindor stole second one pitch before Martinez sent Mets fans home happy in the rubber match of the series with his sixth home run of the season.

It was the first hit by either team with a runner in scoring position. The Marlins were 0-for-5; the Mets were 1-for-5, and one was all it took.

“The guys continue to show up, continue to battle,” manager Carlos Mendoza said. “Today we saw it on a night where it was hard for us offensively. We found a way and we won a baseball game.”

The Mets didn’t get their first hit — or anything close to one — off Munoz until Harrison Bader singled to right with one out in the sixth. Three pitches later, Bader was thrown out attempting to steal second.

Munoz, 24, was making his fifth career start. He came in with a 5.95 ERA and had given up eight home runs in his first four. But he threw six shutout innings.

On the other side, Luis Severino worked into and out of trouble to keep the game scoreless before Jake Burger hit a solo homer off the facing of the second deck in right with one out in the sixth. Severino went six innings and allowed that run and seven hits.

Jazz Chisholm Jr. homered to right-center off Drew Smith with one out in the seventh to give the Marlins a 2-0 lead.

In the seventh, the Mets loaded the bases with no outs. Reliever Anthony Bender fell behind Starling Marte 3-and-0 before throwing a strike and then getting Marte to ground into a run-scoring 5-4-3 double play to make it 2-1.

Diaz’s first inning off the IL from a shoulder impingement went well, with velocity that approached 100 miles per hour.

“I’m feeling 100%,” he said. “I saw I was throwing 99, 100 today. I didn’t do that early in the season. I was locating the pitches the way I want to. My slider was sharp and I just did my job.”

ONE-DAY SALE26¢ for 5 6 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME