NEW YORK — No matter how good Jose Fernandez is, the Miami Marlins aren’t going anywhere this season if they don’t start scoring.

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

It was the latest offensive flop for the slumping 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’ve got to keep moving. I thought our guys had good energy today. They were in the game. There wasn’t a dragging of the heads or anything like that,” manager Don Mattingly said. “We’re going to come out of that and put some runs on the board.”

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. Both teams are 2 1/2 games behind St. Louis for the league’s second wild card.

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

Chasing their first postseason berth since 2003, the Marlins haven’t homered in seven games — their longest drought since April 2013.

Injuries to sluggers Giancarlo Stanton and Justin Bour haven’t helped, but that’s not all of it, Mattingly explained.

“Even before those guys got hurt, it wasn’t exactly a juggernaut,” he said before the game.

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

Recalled from Double-A Binghamton before the game, Montero gave up two hits in five innings and worked around a career-high six walks — most by a Mets starter since May 2014. Still, the Marlins failed to capitalize.

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

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.

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

“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.”

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 went to third on a long flyout, 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. The speedy Reyes scored with a headfirst dive as Ramos crashed into him while going down to his knees and reaching for Realmuto’s throw.

Reyes rolled around in discomfort for several seconds but stayed in the game.

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 put on the disabled list and replaced again by LHP Justin Nicolino, Mattingly said. … 2B Derek Dietrich (bruised right knee), on a rehab assignment at Double-A Jacksonville, is expected to come off the DL in Cleveland on Saturday, the first day he’s eligible. … Miami still hopes Stanton (strained left groin) can return in some capacity during the final week of the regular season, Mattingly said.

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

ROSTER MOVE

Miami added a fresh arm to the bullpen by recalling right-hander Austin Brice from Triple-A New Orleans for his second stint with the big club, both this month. Nicolino, who started Sunday and threw 101 pitches in a 3-1 loss to San Diego, was optioned to the Zephyrs.

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.