Sonny Gray of the Yankees looks on from the mound...

Sonny Gray of the Yankees looks on from the mound after surrendering a fifth-inning home run against Andrew Benintendi of the Red Sox at Yankee Stadium on Friday, Sept. 1, 2017. Credit: Jim McIsaac

Sonny Gray would have been perfectly fine with a bunt or two from the Red Sox on Friday night. Instead, Eduardo Nuñez swung away this time — as did Andrew Benintendi and Hanley Ramirez — and the resulting three-homer barrage did more than merely bruise Gray’s ego in the Yankees’ 4-1 loss, a crippling blow to their fading hopes in the AL East race.

What a sadistic twist of fate. After CC Sabathia spent Thursday night into Friday morning barking about Nuñez’s show of disrespect by bunting — yes, everyone dissected the controversy all over again 16 hours later — Gray got hammered by a trio of long balls that severely sabotaged the Yankees’ September goal of being a legit threat to the division leader.

“It’s frustrating,” Gray said, “because on a night when I felt like I had some good things going for me, I got beat on three swings.”

As irrational as Sabathia’s anti-bunting rants were, seeing the Red Sox take Gray deep three times — they had only five hits in seven innings — was nearly as crazy. In five previous starts for the Yankees, Gray surrendered two homers in 30 innings. He entered Friday night on a roll, with 11 consecutive starts of allowing two or fewer earned runs — the longest streak in the majors this season.

That ended, of course, although Gray matched his Yankees best with nine strikeouts and one walk. The three homers tied his career high, and the four earned runs were his most given up since June 20, when the Astros got him for five.

“It’s one of those where you scratch your head when you look at the linescore,” Joe Girardi said. “The problem is that three of those hits were home runs.”

Another issue? The Yankees develop an allergy to offense when Gray pitches. He’s been backed by either one run or zero in all four of his losses, with the Yankees batting a collective .130 in defeat.

With the mindless entertainment of Buntgate in the hours leading up to Gray’s turn on the mound, it was easy to forget what remained at stake this weekend. Once Hall of Famer Jim Rice, now a Red Sox studio analyst, entered the fray by making cracks from Boston about Sabathia’s “burger weight,” the story grew new legs, to which Sabathia replied Friday, “I just hope when I’m that age I’m not that bitter.”

Lost amid this back-and-forth, however, was the fact that Sabathia had pitched a terrific six innings to beat the Red Sox.

Coming in, the Yankees’ rotation was 8-4 in the last 18 games with a 2.86 ERA, the second-best among MLB starters during that span. The Yankees were being carried by their pitching staff, which had limited opponents to the lowest slash line (.219/.296/.370) in the majors since the All-Star break.

As much as Gray worried about taming the Red Sox, there had to be some relief when Brett Gardner and Aaron Judge led off the first inning with back-to-back doubles for a 1-0 lead. The manner in which that edge disappeared, however, was almost comical after the attention devoted before the game to Nuñez’s right to intentionally poke a baseball 20 or 30 feet.

“I’m skinny. I have to bunt. That’s my game,” Nuñez said in response to Sabathia’s second round of complaints Friday.

With the slimmer, more agile Gray opposite him, Nuñez grounded out to short in his first at-bat but yanked a line drive over the leftfield wall for a two-run homer in the third. Two innings later, with two outs, Benintendi hammered a first-pitch fastball that nearly reached The Judge’s Chambers. Ramirez led off the seventh by launching his 22nd homer into the Yankees’ bullpen.

“I just wasn’t quite good enough,” Gray said.

He would have preferred the bunts.

Newsday LogoYour Island. Your Community. Your News.Digital AccessOnly 25¢for 5 months