NEW YORK —

Said reliever Ryne Stanek, who earned the victory: “That win felt like a deep breath.”

The Mets backed rookie Nolan McLean with a 2-0 lead only for the Rangers’ Joc Pederson to tie the score with a two-run single in the seventh off Reed Garrett.

That set the stage for Alonso’s fifth career walk-off home run.

“He’s powerful,” manager Carlos Mendoza told reporters. “All he’s got to do is just tough it pretty much in those situations, and the ball’s going to go.”

Texas had won six straight games and began the day two games back in both the American League West and for the final AL wild card.

Making his sixth big league start, McLean gave up five hits, struck out seven and walked two, lowering his ERA to 1.19 — the lowest by a Mets pitcher through his first six starts.

Francisco Alvarez raced home from third on Juan Soto’s fifth-inning groundout off starter Jacob Latz, and Brandon Nimmo homered leading off the sixth for the Mets.

“Winning that one right there feels like it will quell some of the outside noise — the noise that’s not coming from in here,” Stanek told reporters. “I feel like we have a really good group that’s mature, that’s veteran, that’s not going to take the noise and magnify it. But if winning today — if that can kind of drown out some of that noise anyway, it’s always a good thing.”

The Associated Press contributed to this report.