Yoenis Cespedes had not faced a pitcher since leaving Friday’s game in pain. Since then, he had his troublesome left leg drained of fluid. He had been so physically limited that until Tuesday, he hadn’t done any pregame work in the field.

But when the Mets needed one big swing from their flamboyant centerfielder, Cespedes delivered in style. The Mets beat the Reds, 4-3, powered by Cespedes’ game-tying, three-run homer to trigger a rally in the seventh.

It came after a few moments of anxiety.

The distance between the indoor batting cages and the home dugout is about 40 steps. But Cespedes took a while to report to the dugout for pinch-hitting duty, arriving only in time to hastily tape his wrists, grab a bat, and walk to the batter’s box.

Cespedes’ shot, a low 1-iron that tested the structural integrity of the leftfield stands, came on the first pitch he saw against Reds lefthander Brandon Finnegan. The first pinch-hit homer of Cespedes’ career erased a 3-0 deficit and revitalized a lineup that had been stifled.

“You just shake your head,” manager Terry Collins said. “Like I said, special people do special things.”

advertisement | advertise on newsday

Two batters later, David Wright lined an RBI single to push across the game-winning run, scoring Curtis Granderson, who scorched a one-out triple that extended the rally.

In the dugout, Cespedes shared the same wide-eyed expression that he had just given the rest of his teammates. The sudden reversal of fortune came on a night in which his status was uncertain.

“Flair for the dramatic,” said Wright, whose clutch hit erased what had been a rough night at the plate. “It was right out of a movie scene.”

The Mets won for the 10th time in their last 12 games. They have won five straight, their longest winning streak this season. And for the first time this season, they had come back to win a game.

Before the first pitch, Collins wasn’t certain that Cespedes would be available. He had hoped a pinch-hitting spot might arise, but there were no guarantees.

Mets videos

The problem was inactivity. Cespedes, who did not address the media after the game, originally injured his left leg on April 13 on his ill-fated dive into the stands. He had been playing with a large bruise on his leg. On Friday, it became an issue when he slid into second base.

But in the fifth, hitting coach Kevin Long assured Collins that Cespedes would be ready. Except, when the pitcher’s spot came up with two on in the seventh, Collins couldn’t find his slugger.

In the confusion, Collins called for Lucas Duda to grab a bat and begin swinging in front of the dugout. Reds manager Brian Price visited the mound but left starter Brandon Finnegan in the game, which he later said would have been his decision regardless of who hit.

So, was it all a decoy? Later, Collins gave a few coy answers, though he admitted he told Duda he was not going to hit.

After Price retreated, Cespedes emerged bat in hand with Duda never having been announced as the pinch hitter. In the dugout, second baseman Neil Walker said the Mets wondered aloud what the slugger would do in spot duty, or if he could even run the bases if he drove a ball into the gap. They could barely stage their arguments before Cespedes sent Citi Field into a frenzy.

advertisement | advertise on newsday

His drive hit the wall behind the fence, rocketing it back into the field of play. The runners behaved as if the ball were still live, only slowing when umpires signaled it was a homer.

Soon, pandemonium ruled.

“I couldn’t believe it,” Walker said. “We were still in shock.”

Notes & quotes: Zack Wheeler threw for the first time since undergoing a minor procedure to remove a stitch that hadn’t dissolved from his Tommy John surgery . . . Long Island’s Steven Matz will host 32 first responders and military personnel on Wednesday as part of his new “Tru 32” ticket program. He intends to host groups every Wednesday home game.