The Yankees' Matt Carpenter is greeted in the dugout after...

The Yankees' Matt Carpenter is greeted in the dugout after hitting a solo home run during the fourth inning of a game against the Red Sox at Fenway Park in Boston on Friday, July 8, 2022. Credit: EPA-EFE/Shutterstock/CJ Gunther

BOSTON — Nestor Cortes, dominant during so much of the season’s first half, wasn’t good at all Friday night.

But Boston’s pitching was far, far worse and the Yankees took advantage, scoring in seven of the nine innings and getting a home run from Josh Donaldson for a third straight night as they cruised to a 12-5 victory in front of 36,841 at Fenway Park.

Donaldson’s three-run homer highlighted a four-run first inning and Joey Gallo later had a fluke two-run triple for the Yankees (a season-high 38 games over .500 at 61-23 and 16 games ahead of the Red Sox). Matt Carpenter, who started in leftfield and homered, and Gleyber Torres had three hits each as the Yankees outhit the Red Sox 14-13.

Carpenter, who Aaron Boone said has continued to “earn” more consistent playing time, said of the Yankees’ 15 1⁄2-game division lead: “It just shows you how talented this clubhouse is and what kind of players we have in here and what we’re able to accomplish. This is a really good division, and to have the lead that we do is a testament to the guys in this room. But at the same time, we’re not really thinking about that. We really do a good job of coming in every day and just putting on the gas, getting back to work. Just coming out ready to play every day.”

Said Giancarlo Stanton: “We’re incredible. We find ways to win nonstop and we’re just hungry. We stay hungry. It doesn’t matter how far ahead we are or what obstacle’s in front of us. Just keep pushing.”

The injury-plagued Red Sox (45-39) not only have lost 11 of 15 but lost another starting pitcher — Connor Seabold, who left after 2 2⁄3 innings with right forearm extensor tightness — as well as Yankees/Gerrit Cole-killer Rafael Devers with lower-back pain. Boston’s final pitcher of the night was outfielder Jackie Bradley Jr., who struck out DJ LeMahieu but allowed a run in the ninth.

Cortes allowed four runs and eight hits in 3 2⁄3 innings, but winning pitcher Miguel Castro and Lucas Luetge recorded key outs and Luetge pitched the final 3 1⁄3 innings for the save.

Even after falling behind by a large margin early, the Red Sox had chances to get back in the game. With the Yankees leading 5-2 in the second, Devers popped up with runners on first and third to end the inning. Trailing 9-2 in the fourth, the Red Sox got solo home runs from Trevor Story and Bobby Dalbec and loaded the bases with two outs, but Castro struck out Christian Vazquez. With the Yankees leading 9-5 in the sixth, Boston loaded the bases but Story popped up against Luetge. At that point, the Red Sox had left 11 men on base.

“It was everyone,’’ Boone said. “DJ at the top setting the tone for us, Carp, Gleyber, JD, Hicks, everyone contributed. Did a lot of good things on the bases. Caught the ball.

“They’re heavy. We get up 9-2 and here they come. You know here, especially, they’re never out of it, so you never feel comfortable, really. So it was good we were able to add on late and give us that cushion.”

Five batters into the game, the Yankees led 4-0, thanks to Torres’ RBI single and a three-run homer to left over the Green Monster by Donaldson, who had a grand slam Thursday night. And it could have been worse; Devers had robbed Aaron Judge of a double.

Singles by former Yankee Rob Refsnyder (four hits) and J.D. Martinez and a two-out, two-run double off the top of the Green Monster by Vazquez made it 4-2 in the bottom of the first.

Carpenter’s two-out RBI double in the second gave the Yankees a 5-2 lead and the Yankees lucked into a pair of runs in the third.

Aaron Hicks led off with a walk and Jose Trevino doubled to left. One out later, Gallo hit a routine fly ball to right — and Christian Arroyo never saw it. With arms outstretched, he screamed “I can’t see it!’’ and looked much like Yankees rightfielder Lou Piniella in the ninth inning of the 1978 playoff game between the teams when he lost Jerry Remy’s soft line-drive single in the sun.

In Piniella’s case, he recovered and stabbed the ball to prevent the tying run from getting to third; in this case, the ball landed well beyond Arroyo. Hicks and Trevino scored easily and Gallo, trying for the inside-the-park homer, was thrown out at the plate (he was credited with a two-run triple).

Carpenter hit his ninth homer to make it 8-2 in the fourth. Michael Feliz then walked Donaldson and Hicks with one out, they pulled off a double steal, and Donaldson scored when Vazquez’s throw to third skittered into the outfield.

Marwin Gonzalez’s safety-squeeze bunt made it 10-5 in the seventh. Torres had an RBI double in the eighth and Isiah Kiner-Falefa walked with the bases loaded against Bradley in the ninth.

Is it easier for Cortes to take this kind of outing when the offense does what it did? “Definitely,’’ he said. “I think it’s most important when we win a game no matter what individually we do. Obviously, I want to be out there for the fifth and sixth inning, possibly get the win, but as long as we’re winning, nothing else matters, to be honest.”

More Yankees headlines