Yoenis Cespedes had not faced a pitcher since leaving in pain on Friday. 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.

None of that mattered.

When the Mets needed one big swing from their flamboyant centerfielder, Cespedes hopped off the bench, grabbed a bat, then delivered in style. The Mets beat the Reds, 4-3, powered by Cespedes’ game-tying three-run homer in the seventh.

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.

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.

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

“We’re hoping we can use him tonight,” Collins said. “He’s feeling a lot better. He actually said if we needed him he could play tonight. Wanted to play.”

The problem was inactivity. Cespedes 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.

Until he stepped into the batter’s box in the seventh inning, Cespedes had been nothing more than a spectator. And for a moment, it appeared it would stay that way.

In the seventh inning, when the pitcher’s spot came up with one down and a pair of runners on, Collins sent lefty Lucas Duda to the front of the dugout. He swung a weighted bat as if he were to hit and Finnegan remained in the game.

Only then did Duda get called back in favor of Cespedes. Until then, it appeared that Mets had finally been slowed.

The Mets have won five in a row and 10 of their past 12 games. In their previous 10 contests, they had bashed 26 home runs. According to the Elias Sports Bureau, that outburst tied for the most for any 10-game stretch in the history of the franchise.

Entering play on Tuesday, the Mets had averaged 5.9 runs in their last 10 games. But Finnegan outdueled veteran Bartolo Colon, who surrendered three runs in five innings, including a two-run shot by Ivan De Jesus Jr.

Finnegan had just turned away a Mets rally in the sixth, when the middle of the order failed to deliver after consecutive hits by Granderson and Asdrubal Cabrera gave the Mets runners on the corners with nobody out.

One inning later, Cespedes wiped away the sting with one timely swing. Matt Harvey takes the mound on Wednesday in position to give the Mets their second-straight series sweep.

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 reliever Logan Verrett could be used in more late-game situations. He surprised the coaching staff by warming up quickly to enter Monday night’s game. On Tuesday, he picked up the win after two scoreless innings of relief . . . 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 through May.