From left, Cody Bellinger, Trent Grisham and Aaron Judge of the Yankee celebrates...

From left, Cody Bellinger, Trent Grisham and Aaron Judge of the Yankee celebrates after defeating the Mets at Citi Field on Sunday. Credit: Getty Images/Justin Casterline

Maybe the Yankees weren’t in full-blown panic mode Sunday for the Subway Series finale, but they were toeing the brink of catastrophe. And by our estimation, the distance separating them from that cliff’s edge came down to a few inches — or the very tip of Cody Bellinger’s outstretched glove.

After a full week spent flirting with disaster, failure wasn’t an option for the Yankees. Not riding a six-game losing streak, falling out of first place and watching the Mets go the white flag route in sending out reliever Chris Devenski to counter their ace, Max Fried.

While it’s tough to label any game a must-win short of a late-September playoff chase, you could say this one satisfied the criteria for the Yankees. And when Juan Soto’s sinking liner in the seventh inning raced Bellinger’s glove to see which would get to this particular patch of leftfield grass first, manager Aaron Boone felt himself getting that sinking feeling in his gut — again.

The Yankees were clinging to a 6-4 lead, Francisco Lindor was at first base and the Mets had the tying run at the plate in Soto with none out. When Soto smoked a 105-mph laser toward the onrushing Bellinger, the expected batting average of that ball was .730 — favorable odds to cause serious trouble.

“Not good,” Boone said. “Not good.”

Any day of the previous six, that line drive drops, the Mets rally and Boone has to explain yet again why his “best team in the league” pep talk from Toronto keeps backfiring. But not Sunday. This time Bellinger impossibly made the grass-skimming grab (without an inch to spare) and just as incredibly fired a bullet to first base that doubled off Lindor.

“Considering the context of this week and everything,” Boone said, “that’s probably our play of the year so far.”

Said Bellinger: “Definitely a tough play. Those ones that are low, they’re kind of hard to read, but in that moment, I felt like I could go get it. I had a good bead on it, a good jump, and I was glad I was able to get it before it hit the ground.”

The fact that the Yankees needed Bellinger’s fielding miracle to hold on for Sunday’s 6-4 victory speaks to the desperate straits Boone’s crew was in. The Mets already had picked up the unlikely series win by taking the first two games, deploying emergency starter Justin Hagenman and the shaky Frankie Montas to do so. For the finale, manager Carlos Mendoza — who could barely contain a smile when I asked him before the game about his good fortune — planned to empty the spare parts in his bullpen for the try at a sweep.

If not for Bellinger’s defensive brilliance, Fried coming up big when it counted most and the Mets committing a few baserunning blunders, this one actually could have gone Mendoza’s way. But the Yankees remembered their winning formula just in time, along with leaning on Aaron Judge, who had a two-run homer (No. 33) and three RBIs. Judge also made a run-saving diving catch in the sixth.

“Every game’s important,” Judge said. “Doesn’t matter what happened before or what’s coming up. It’s just about today. We were focused on today. We weren’t worried about the past six games, the past 10 games, the past 70 games. We were worried about what we had today in front of us.”

Ideally, sure. But a day earlier, an unaware Judge got clocked in the face by a 50-yard heave from Anthony Volpe as part of an inning-ending ritual gone awry. Another inch or two there, and Judge — who was bloodied enough to require a bandage Saturday — isn’t in Sunday’s lineup. Maybe even questionable for the rest of this season, or worse.

Based on Judge’s MVP-caliber performance in the finale, the captain appears fine. And Fried, who improved to 11-2, showed why he’s a front-runner for the Cy Young Award by grinding through five innings-plus (six hits, three runs) that easily could’ve spun out of control.

The peak of those crisis moments occurred in the fifth inning, right after Lindor stung him for a two-run single.

Up came Soto with two on, and Fried toyed with the $765 million slugger, baffling him with 85-mph sweepers and 75-mph curveballs. Soto stayed off two pitches in the dirt, but with two strikes, he swung wildly at the third for the punch-out. Fried then got Pete Alonso to fly out, ending the threat, but it felt as if the game hinged on that Soto strikeout.

“We’re still a very confident bunch,” Fried said. “It’s nice to get a win after being on a little bit of a losing streak, but that’s the way we want to do it. It’s a good team win. It took everyone to get it.”

Think of the alternative. With the victories by the Blue Jays and Rays, the Yankees would have dropped into third place, four games behind first-place Toronto, if the Mets somehow had stolen the sweep.  That’s no way to enjoy Monday’s off day after playing 26 games in the previous 27 days.  Instead, they got a face-saving W they absolutely had to have, and the Subway Series ended in a 3-3 tie for the season.

“It wasn’t going to be easy,” Paul Goldschmidt said. “It’s not going to be easy this whole year.”

Problem is, nobody expected the Yankees to make it look quite this hard.

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 6 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME