ARLINGTON, Texas — An offense that took nearly eight innings to wake up Saturday was ready from the word go Sunday.

Taking advantage of some truly hideous pitching, the Yankees got four hits and four RBIs by Didi Gregorius and two homers apiece from Gary Sanchez and Aaron Judge in pounding the Rangers, 16-7, at Globe Life Park.

The Yankees (77-65), 4-2 on a nine-game trip that continues Monday night against the Rays at Citi Field because of Hurricane Irma, crept within 3 ½ games of the AL East-leading Red Sox.

“I think we’re definitely close enough where we can catch up to the Red Sox,” said Brett Gardner, whose two-run triple jump-started a six-run fourth inning that gave the Yankees a 9-1 lead. “I really don’t worry about what they do, I worry about what we do. I feel like if we play the best baseball we’re capable of playing, then we’ll catch them.”

The Yankees couldn’t have been much better offensively Sunday, tying their season high in runs and hits (18), including the homers by Judge (Nos. 40 and 41) and Sanchez (Nos. 29 and 30), five doubles and a triple.

“It’s incredible what these kids have done,” Joe Girardi said of the pair. “And there’s still three weeks to go, and they’ll continue to add to those numbers.”

advertisement | advertise on newsday

Judge, 25, became only the second rookie, joining Mark McGwire, to hit 40 homers in a season. He is the 11th Yankee to reach the plateau and the fifth Yankee to reach 40 homers in their age-25 season or younger, joining Mickey Mantle, Joe DiMaggio, Lou Gehrig and Babe Ruth.

“Pretty surreal,” said Judge, who has 90 RBIs. “Never as a kid would I ever think that I’d be in the same sentence as those guys. Quite an honor. It’s pretty humbling.”

Judge’s second homer of the day — which sailed over the Yankees’ bullpen in left-center and was estimated to have traveled 463 feet — produced a 12-4 lead in the sixth.

Sanchez blasted one 461 feet to dead center in the eighth to make it 13-4, giving him 13 homers and 31 RBIs in his last 28 games. “Right now I’m seeing the ball pretty well,” he said through his translator. “I was looking for high pitches today to make good contact and that’s what [happened] and I’m getting good results.”

Gregorius’ two-out, two-run single in the fifth made it 11-3. Austin Romine added three hits and scored three runs and Sanchez scored four times. In his first at-bat as a Yankee, catcher Erik Kratz, acquired Aug. 31 from the Indians, cracked a two-run double in the ninth to make it 16-6.

Yankees videos

Aside from Dellin Betances — who struck out the side in the eighth but allowed two walks and a two-run double by Shin-Soo Choo — rookie lefthander Jordan Montgomery provided the only negatives on the day, lasting only 3 1⁄3 innings and allowing three runs, three hits and four walks. After being given the 9-1 lead in the fourth, Montgomery walked the first two batters of the bottom half. Ryan Rua’s one-out RBI double made it 9-2, and Girardi brought on Chad Green to stifle any hopes of a rally.

Green brought a 1.55 ERA since June 18 into the game but wasn’t as dominant as usual, allowing one run and four hits in 2 1⁄3 innings. He did strike out four, giving him 96 in 63 innings, and was credited with the victory.

On this day, however, what happened on the mound was rendered irrelevant. The bats ruled this day, allowing the Yankees to win a third straight series.

“This time of year, you need to win series,” Girardi said. “If we’re going to accomplish what we want to accomplish, we need to do that, especially with the teams we’re playing.”

Said Judge: “We keep playing our game, good things will happen and we’ll be where we want to be.”