Jazz Chisholm Jr. of the New York Yankees celebrates his...

Jazz Chisholm Jr. of the New York Yankees celebrates his eighth-inning home run against the Boston Red Sox at Yankee Stadium on Sunday. Credit: Jim McIsaac

The last time the Yankees found themselves in the dire predicament they faced Sunday night, Joe DiMaggio  was batting cleanup and Ted Williams was a 20-year-old rookie. It was 1939, when the Red Sox swept a five-game series in the Bronx shortly after Lou Gehrig gave his legendary farewell speech.

But rather than share in a similar degree of dishonor, the Yankees rose up from that historical ineptitude, using their favorite crutch as Jazz Chisholm Jr. and Trent Grisham each went deep twice  to power a 7-2 victory over the Red Sox.

Chisholm’s two-run blast in the second inning, No. 100 of his career, put the Yankees in front to stay and finally ended the Yankees’ losing streak against Boston at a humiliating eight games.

“We definitely needed this win tonight,” he said.

The Yankees’ surest path to victory always involves a slow trot around the bases, and with four more home runs Sunday night, they lead the majors with 215 — well ahead of the next-up Dodgers, who have 196.

When they have smashed at least two homers this season, the Yankees are 38-19; when they’ve been kept in the ballpark, they’re 11-21.

Red Sox starter Dustin May proved to be a willing accomplice, teeing up three of the home runs. Grisham took him over the rightfield wall in the fifth inning for his second homer of the game, No. 25 on the season. By then, Red Sox manager Alex Cora was ready to wave the white flag, although Boston did keep it close until Chisholm’s second homer, a two-run shot off Walker Buehler in the eighth.

“When everything’s going well, I think that’s how we are — we hit homers, we score a lot of runs and we walk a lot,” Chisholm said. “And I feel like that was our game tonight.”

That also explains why the Yankees had dropped the previous eight to the Red Sox. They batted .193 in those losses, totaling seven homers, and were outscored 48-22.

The Yankees’ season wasn’t at stake Sunday night, but at some point, they had to show some guts, if not the ability to play winning baseball against a longtime rival that clearly has enjoyed pantsing them this season.

“It’s been fun — I’m not gonna hide it,” Cora said before Sunday night’s series finale.

Cora’s crew had savaged the Bronx with obvious glee, as the Yankees had more errors (five) than runs (four) through the series’ first three games. By Sunday night, as ESPN hoped a national audience would tune in for the potential car crash, only one question remained:

What lengths would the Yankees go to in order to stop getting embarrassed?

A few of those answers were revealed shortly after 3 p.m. when we got our first look at the lineup card posted on the clubhouse door.  Jose Caballero had replaced the spiraling Anthony Volpe at shortstop — for the second time in a week — and Giancarlo Stanton was back in rightfield despite all the mileage he logged out there Saturday afternoon,   especially while chasing down a half-dozen hits in a wild ninth inning.

Translation: The Yankees apparently were done tiptoeing around their biggest daily issues, protecting Volpe’s now-loosening grip on the everyday shortstop job and pushing their luck with Stanton’s fragile health status.

The moves worked out well Sunday, as Caballero played a solid shortstop, delivered a sacrifice fly and replaced Stanton in right when Boone made his defensive substitutions for the eighth inning (Volpe entered at shortstop).

Boone can’t afford to have Volpe as a pinstriped passenger when he’s more part of the problem than a solution, and the deadline acquisition of Caballero finally gave him the option of sitting the third-year shortstop, a strategy that was long overdue. If Caballero proves productive in that role, there’s no point in rushing Volpe back, either.

As for Stanton, he went 2-for-3 with a 118-mph double and again survived another night of defensive duty.

We’re not exactly sure why it took this long to put the struggling Volpe on notice. He’s been among the sport’s worst players going on months now, both at the plate and defensively. But in Stanton’s case, the Yankees’ need to have his bat in the lineup has overtaken the physical risk, and it’s not as if they have a choice with Aaron Judge still a while away from returning to his position.

“We’re at the all-hands-on-deck portion of the season,” Boone said before the game.

With five weeks left, the Yankees are sandwiched between the Red Sox and Mariners in the second wild-card spot, separated by a half-game above and below, and are three games ahead of the Royals, who have established themselves as a legit contender down at No. 4. But Sunday’s finale wasn’t so much about firming up playoff positioning as it was pushing back on the Red Sox.

In the short term, the Yankees finally figured out how to beat Boston, using their most tried-and-true method, preserving some measure of self-respect before the lowly Nationals come to town this week.

“We knew we had to win,” Carlos Rodon said. “And the boys swung the bat well.”

Let’s see what happens when they meet again next month at Fenway Park.

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 6 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME