SEATTLE — Aaron Judge got Yankees fans to all rise once again.

Indeed, the rightfielder isn’t going to go homerless in the second half after all.

Judge, in his first prolonged slump of the season, hit his first home run of the second half Friday night in helping the Yankees to a 5-1 victory over the Mariners in front of 34,073 at Safeco Field.

The monstrous three-run shot in the fifth inning off Andrew Moore nearly left the ballpark, landing in the third-to-last row of the second deck at Safeco, a place seldom, if ever, visited by baseballs, even during batting practice. It was estimated at 440 feet.

“[Hitting coach] Alan Cockrell, who worked here, said it’s the farthest ball he’s seen hit here in a game or BP,” Joe Girardi said. “It was quite impressive. And it came at a great time.”

CC Sabathia said: “I thought the ball was going out of the stadium.”

advertisement | advertise on newsday

Its grand elliptical arc resembled quite a few of the balls Judge put into orbit in Miami in capturing the Home Run Derby crown July 10 and had his teammates gleefully pointing and exchanging high-fives.

“It’s not fair,” David Robertson said. “It’s like he’s playing on a Little League field. I’ve never seen anyone hit a ball like that. I don’t know what to say. I just hope he keeps doing what he’s doing because it’s impressive to watch.”

Judge was the least excited of anyone. “I’m just glad to be in that position,” he said. “Guys were getting on base all night for me and in that situation I’m trying to get something up in the air and score the run.”

The homer gave the Yankees (50-45) a 5-1 lead, gave Judge his MLB-leading 31st home run and, perhaps, was the beginning of the end of the narrative gaining steam that his participation in the Home Run Derby had caused his 4-for-30 slide to start the second half.

Does Judge feel like he’s back on track?

Yankees videos

“It’s baseball,” he said, “you’re going to have 0-for-4s, 1-for-20s, and you’re going to have those times when you’re 10-for-11 and you can’t get out. It’s just part of baseball.”

There was plenty else to like from the Yankees perspective.

There was a brilliant defensive play by leftfielder Clint Frazier, a diving catch that saved a run early, and an RBI double a half-inning later by the rookie that tied it at 1.

CC Sabathia, celebrating his 37th birthday, overcame some control issues early to pitch five solid innings in which he allowed one run and four hits, improving to 9-3 with a 3.44 ERA. The lefthander came in 6-1 with a 1.60 ERA in his previous eight starts.

And Girardi got to deploy a few key pieces of his power ’pen, Tommy Kahnle, Robertson, Dellin Betances and Adam Warren.

advertisement | advertise on newsday

Kahnle struck out one in a scoreless sixth and Robertson, making his first appearance since the trade, struck out the side in the seventh. Betances allowed two hits in the eighth but struck out two in a scoreless inning. Warren pitched a scoreless ninth.

The Yankees, in good position to win their first series since June 9-11 against Baltimore, had 11 hits, three by Didi Gregorius and two by Chase Headley. Judge had four RBIs.

Moore, making his fifth career start, allowed five runs and nine hits in six innings, falling to 1-2, 5.70.

He did pitch with an early lead. Robinson Cano walked with two outs in the first and Nelson Cruz lined a 1-and-0 changeup off the base of the wall in left for a long single.

Kyle Seager sent a sharp grounder that glanced off the glove of a diving Headley at first. The ball deflected to Starlin Castro at second but Headley could not find the bag on his return throw and Cano scored to make it 1-0. Mitch Haniger singled to right to load the bases but Sabathia got Guillermo Heredia on a forceout to end the 22-pitch inning.

advertisement | advertise on newsday

Frazier helped Sabathia keep the deficit at one in the second.

Former Yankee Ben Gamel led off with a double. Mike Zunino then sliced one to left where Frazier, running toward the line, laid out and made a diving catch. Sabathia pointed at the 22-year-old in appreciation.

The Yankees took the lead for good in the third. Headley improved to 11-for-30 on the trip with a leadoff double and Frazier jumped on a first-pitch slider, driving it off the wall in right-center to tie it at 1. Frazier tagged and went to third on Brett Gardner’s flyout to center and came in on Judge’s sacrifice fly to the track in center.

Sabathia stranded six runners over the first three innings before settling in, retiring eight straight after hitting Seager with a pitch with one out in the third.

“It was a battle,” Sabathia said of his outing. “Tonight wasn’t my best stuff but I was confident in the guys to score runs and the bullpen would pick me up and that’s what happened.”