The Yankees' Giancarlo Stanton celebrates his walk-off two-run home run...

The Yankees' Giancarlo Stanton celebrates his walk-off two-run home run against the Mariners at Yankee Stadium on Wednesday. Credit: Jim McIsaac

They had the lightning. Then they had the thunder.

One inning after Gary Sanchez tied the score with a massive two-run home run, Giancarlo Stanton had his first signature moment as a Yankee. Stanton hit an 0-and-2 slider for a two-run, walk-off homer in the ninth as the Yankees beat the Mariners, 7-5, before a sellout crowd of 46,047 Wednesday night.

“It was bound to happen at some point,” Aaron Judge said. “Him hitting a walkoff homer. That’s what he does.”

He hadn’t done it in pinstripes. Stanton’s 18th home run went deep into the night to left-center and was estimated at 453 feet with an exit velocity of 117.9 miles per hour. It was Stanton’s first walk-off homer as a Yankee and the fourth of his career.

“That ball was killed,” Aaron Boone said.

“I didn’t even watch it,” Judge said. “I saw it off the bat and I just tried to hop that little fence and get out there. What a swing by him.”

The Yankees, who trailed 5-0 after 4½ innings, picked up their 23rd comeback win. That includes games in which they trailed 1-0 after one-half inning, but this was a substantial rally. It was their sixth walkoff win of 2018 and third via the home run.

“As you all know, we have a really good lineup,” Sanchez said through a translator. “Really good hitters. When you have a good team, playing good baseball, the way I see it, five runs is not going to be enough.”

With the Yankees trailing 5-3 in the eighth, Gleyber Torres led off with a walk against Alex Colome before Sanchez unloaded on a 1-and-1 pitch. Sanchez’s 14th home run traveled an estimated 439 feet.

Then came Stanton’s blast off Ryan Cook (1-1) that scored Didi Gregorius, who singled with two outs. Stanton has struggled at home, against righthanders, and late in close games.

One swing changed all that.

“It’s huge, man,” Stanton said. “Just helped us get a win and especially how we came back from 5-0. It’s huge.”

The Mariners scored three runs in the fourth inning against Jonathan Loaisiga and Chasen Shreve and two in the fifth against Shreve.

The Yankees made it 5-2 in the fifth against former Cy Young Award winner Felix Hernandez. Judge lined a two-out RBI single, and a second run scored when leftfielder Denard Span booted the ball.

Gregorius had a sacrifice fly in the seventh to pull the Yankees to within two runs. The stage was set for Sanchez, and then Stanton, and they delivered.

“Excited for two of our big boys to deliver in a big way,” Boone said.

Sanchez had a tough night before his big swing. He was dropped by Boone to sixth in the order for only the third time this season. Sanchez also took a ball off the mask and was hit in the left triceps by a pitch in the sixth inning. (Stanton also was hit by a pitch in the sixth.)

“They hurt,” Sanchez said. “It’s a part of the game and it’s a matter of seeing how I feel [tomorrow].”

Also painful for Sanchez was the .191 batting average he brought into the game.

“It definitely felt good right there to be able to tie the game,” he said. “And, yeah, this has been tough, but I never put my head down. It’s always a matter of working. Keep working.”

The win went to Aroldis Chapman (3-0), who pitched a perfect ninth. The pitching star was Jonathan Holder, who threw 2 1⁄3 scoreless innings of relief. Judge had three hits. Sanchez had the tying home run and a welt on his triceps that may keep him out of Thursday afternoon’s series finale.

But the lasting memory will be Stanton’s. Asked if it was his biggest hit as a Yankee, Stanton — who has been handling questions about his struggles with one-word responses — said: “Yup. Pretty sure.”

That said it all.

More Yankees headlines