CHICAGO — Jeurys Familia envisioned the whole thing, how the madness would unfold, from the bowling-ball sinker he’d bury at the bottom of the zone, to the dangerous slugger’s failed attempt to leg out a double play ball.

“I always do that,” Familia said, on a tactic he’s leaned upon when his heart races, when he must calm his nerves, when he must remind himself to breathe.

Nobody else could see this, of course, certainly not the screaming fans at Wrigley Field. And though his teammates later insisted to a man that they shared his vision, this was difficult to believe.

After all, the bases were loaded with nobody out in the bottom of the ninth, a one-run lead fading fast, the Cubs one hit away from sending the Mets to doom and ending Familia’s consecutive saves streak. All of it spelled defeat.

But soon, everybody would see.

And needing two outs to restore order, Familia unleashed his sinker, Kris Bryant beat it into the ground, and the vision was fulfilled. Double play. With that, the Mets held off the Cubs, 2-1, Tuesday night and Familia had again defied the odds.

advertisement | advertise on newsday

“If I put that negative thing in my mind, that’s going to happen,” Familia said, insistent that he never saw failure, not once. “I just try to believe and think I can do it. I talk to myself.”

Noah Syndergaard allayed concerns about what had been a dead arm, lighting up the radar gun while allowing only an unearned run in 5 2/3 innings. Jose Reyes tripled to set up a run. And light-hitting backup catcher Rene Rivera knocked in the game-winner with an RBI single in the ninth.

But none of it would have counted unless Familia had again summoned the nerve to untangle a mess of his own making. He allowed the first three runners to reach base — the first two on walks — before recording his 33rd consecutive save to start the season.

“He’s a special guy,” manager Terry Collins said. “That’s why I think he’s as good as there is in baseball.”

The Mets closed to within 5 1/2 games of the Nationals, who lost. And they remain a game behind the second-place Marlins, who won. On Wednesday, the Mets still can emerge with their second straight series win to begin the second half.

Mets videos

That opportunity exists only because Familia slammed the door. He has not blown a regular-season save since July 30 of last season, a streak of 49.

But buried within the statistical simplicity of that streak has been Familia’s propensity for drama. His outings have been white-knuckle affairs, featuring trouble at every turn. He has invited trouble with walks and sudden bouts with command that have brought him to the brink.

Said Collins: “Nobody’s more frustrated that he gets in those situations than he is.”

It’s bound to bite him. And on Tuesday, the Friendly Confines sprang to life at the promise that the day finally had come.

Addison Russell walked to lead off the ninth, the tying run. Miguel Montero reached on another free pass, this time on four pitches, the go-ahead run.

advertisement | advertise on newsday

Javier Baez took a first-pitch ball — the ninth straight time that Familia missed the strike zone. Two pitches later, he dropped a bunt down the third-base line, a sacrifice turned into a single.

Familia had inspired flashbacks to June 30, when the Cubs had second and third, nobody out in the ninth inning at Citi Field, and survived. But this was worse.

With the bases loaded, pinch-hitter Matt Szczur grounded to first, which turned into a force at the plate. Now, only Bryant remained, and Familia’s mind drifted toward his vision.

On his 22nd pitch, it would become a reality. Bryant beat a grounder to third, and Jose Reyes began the double play that led to the release. Familia extended his arms and yelled, nearly dropping to his knees.

Said Rivera: “We’ve seen what he can do.”