SEATTLE — The Mariners figured out how to stop giving up home runs to Gary Sanchez: Just walk him.

The rookie catcher was issued two intentional walks in the Yankees’ 5-0 win — after he hit his ninth homer in 18 games since being recalled from Triple-A Scranton/Wilkes-Barre on Aug. 3.

And both times Wednesday, Mark Teixeira stood in the on deck circle. Teixeira has 404 home runs in his career, yet he couldn’t disagree with Seattle’s decision.

“If Babe Ruth’s behind him, you intentionally walk him,” Teixeira said. “I’m hitting .195. Of course you walk him. … He’s as hot as any player I’ve ever played with in my entire career. You just don’t see guys doing what he’s doing — I don’t care how old he is.”

And the 23-year-old Sanchez did just fine behind the plate, as well, guiding Masahiro Tanaka through seven scoreless innings as the duo worked well together for a second straight start.

The combination helped the Yankees win their fourth game on this six-game West Coast trip and now, they will turn their focus to the final 36 games of the season — 30 of them against teams in the AL East.

And if the Yankees are actually going to at least put a scare into their division rivals, Sanchez will be a key part of it.

Manager Joe Girardi compared Sanchez’s start to that of Dellin Betances, who was an All-Star as a rookie and quickly became a force out of the bullpen.

“What Gary is doing is phenomenal,” Betances said. “I’ve never seen anything like it. You kind of anticipate him hitting a home run every AB.”

Let’s not get carried away. He also ripped a double down the left-field line to start the fifth and reached base four times Wednesday.

“When I got here, I expected to get some at-bats,” Sanchez said through a translator. “Now, I’m playing every day and it’s really good for me.”

With his first-inning blast, Sanchez became the fifth player in MLB history — since 1913 — to hit nine home runs in the first 21 games of his career.

He hit a towering pop-up to third in his next at-bat before drilling his sixth double of the season. At that point, the Mariners had seen enough, although they got some help from Didi Gregorius.

After Brett Gardner led off the seventh with a single, Gregorius bunted him to second.

Gregorius admitted he bunted on his own to get Gardner into scoring position for Sanchez, but manager Scott Servais took advantage of the open base and walked him.

“He’s earned it,” Servais said. “He did a lot of damage against us. … I certainly respect Mark Teixeira and what he’s done in his career — I’ve seen a lot of it — but watching the game with the naked eye, it’s obvious who’s hot and Sanchez had a heck of a series.”

Teixeira made them pay with an RBI single to left.

In the ninth, Gregorius doubled and Seattle walked Sanchez again — even though it loaded the bases with no one out.

“It’s part of the game,” Sanchez said. “I’m hitting the ball well. I see why they walked me.”

The move was certainly logical, albeit rare.

“You don’t see it very often,” Girardi said. “It means Scott Servais is probably paying attention to how he’s swinging. I’ve never seen a young player come up and do what he’s done as a manager.”

No one has.

“He’s the hottest hitter right now in all of the major leagues,” Betances said. “He can hurt anybody at any time — that’s what’s crazy. [But] I’ve known Gary for a while and that [power] was something he always had. He’s developed as a catcher. Calling games, blocking balls, I’ve been more impressed with that. Obviously, he’s hitting a home run every other game — or every game — but what he’s doing behind the plate [is better].”