NEW YORK — When the New York Mets need a big hit, Yoenis Cespedes is their man.

That’s why his health is so critical to the defending NL champs.

Cespedes homered with two outs in the bottom of the 10th inning to give New York a 2-1 win over the slumping Miami Marlins in the first game of a pivotal series between National League playoff contenders Monday night.

It was a rousing triumph for the Mets, who appeared overmatched on the mound in the opener of a four-game set. New York was shut out for six innings by Marlins ace Jose Fernandez, but Rafael Montero also put up zeros in his first major league start since April 2015.

“It was one of those games that you don’t expect to go win,” Mets manager Terry Collins said.

Jose Reyes dashed home to score the tying run in the eighth on a dangerous collision at the plate, and the Mets pulled even with Miami for second place in the NL East. With its seventh victory in nine games, New York remained 2 1/2 games behind St. Louis for the league’s second wild card.

Recalled from Double-A Binghamton before the game, Montero went five innings and worked around a career-high six walks — most by a Mets starter since May 2014. The right-hander yielded only two hits while subbing for Jacob deGrom, skipped in the rotation to rest and regroup following two poor outings in a row.

Rookie left-hander Josh Smoker (1-0) struck out two in a perfect inning against the meat of Miami’s struggling lineup for his first major league win. Smoker, who pitched for the third straight day and fourth in the past five, was all fired up coming off the mound.

“I think everybody had something to do with that win tonight,” he said. “I think there’s going to be a lot more to come and I’m excited to see where this team ends up.”

Cespedes, who sat out Sunday’s loss to Philadelphia after his nagging right quadriceps flared up, launched a no-doubt drive to left-center on a 1-1 pitch from Nick Wittgren (4-3).

“He crushed it. It was one of those, the minute he got it off, you knew it was gone,” Smoker said. “I was ecstatic. It was unbelievable.”

Cespedes tossed his bat high in the air and then chucked away his helmet as he neared home plate. He paused for effect along the third base line, then stepped right into a swarm of jubilant teammates.

“It wasn’t planned. Reyes was telling me to take it easy because I was coming off of an injury. Just played itself out,” Cespedes said through a translator.

The slugger had three hits and is batting .388 with five homers and nine RBIs in nine games since coming off the disabled list.

“They say one bad pitch can change anything, and it happened,” Wittgren said. “I completely messed up on that pitch and put it right down the middle for him.”

It was the latest offensive flop for the Marlins, who have totaled two runs while losing three straight games. They’ve dropped five of seven overall and mustered only 20 runs in their last nine.

“We know how close we are, and we know what we can accomplish, and we’re giving everything on the field,” Fernandez said. “It’s just unfortunate that it’s not happening for us right now.”

Miami broke a scoreless tie in the eighth when Ichiro Suzuki and Xavier Scruggs hit consecutive two-out doubles off Addison Reed.

Reyes opened the bottom half with a double that scooted by a sliding Suzuki in right field as he tried to cut the ball off. Reyes tagged up and went to third on Alejandro De Aza’s long fly to left field, then raced to the plate after A.J. Ramos’ wild pitch.

With the count 0-2 on Cespedes, Ramos threw a high fastball that glanced off the mitt of catcher J.T. Realmuto and went to the screen behind home. Reyes scored with a headfirst dive as Ramos crashed into him hard in the dirt while going down to his knees and reaching for Realmuto’s throw.

Reyes rolled around in discomfort for several seconds, dyed-orange hair visible to all after his helmet popped off. But after Collins and a trainer came out to check on him, Reyes walked back to the dugout with the crowd of 32,188 chanting his name. He remained in the game.

New York could ill afford to lose him — with second baseman Neil Walker and shortstop Asdrubal Cabrera ailing, the Mets did not have a healthy infielder on the bench.

KIDS IN THE HALL

The 42-year-old Suzuki had two hits, increasing his career total to 3,011 and passing Hall of Famer Wade Boggs for 27th place in major league history.

TRAINER’S ROOM

Marlins: RHP Andrew Cashner (finger blister) is scheduled to start Friday at Cleveland after he was scratched Sunday. If he can’t go, Cashner would likely be placed on the DL and replaced again by LHP Justin Nicolino, manager Don Mattingly said.

Mets: Walker missed his second consecutive game with a stiff back. Cabrera (left knee) struck out as a pinch-hitter to end the seventh. Before the game, Collins said Walker’s status for Tuesday was uncertain.

UP NEXT

Marlins RHP Tom Koehler (9-9, 3.85 ERA) pitches Tuesday night against rookie RHP Seth Lugo (1-2, 2.51), set to make his third career start. Koehler grew up in nearby New Rochelle and is 2-6 with a 4.13 ERA in 19 games, 16 starts, against the Mets. Lugo tossed five shutout innings last Thursday in St. Louis to earn his first major league win.