BOSTON — And just like that, the Yankees have clinched the American League East.

OK, that’s overstating the situation. But a critical, 9-6 victory over the Red Sox on Sunday night at Fenway Park did more than avert a four-game sweep and cease the starting-rotation meltdown that threatened — or at least that’s how it felt — to upend everything this club has overcome.

Thanks to Domingo German, a few timely hits and a generous Red Sox defense, the 2019 Yankees attained a season first: Mathematically, they now control their own destiny.

With an 8½-game divisional lead over the Rays, whom they play twice more, and a nine-game advantage over the Bosox, whom they face another eight times, the Yankees could lose all of their remaining head-to-head games with their top two challengers and still win their first division title since 2012 as long as they excel in their other contests.

They’ll truly have no one but themselves to blame if they can’t complete their first task toward a parade.

So yes, for multiple reasons, this certainly goes down as a big victory. There’s a reason the players blasted music in their clubhouse, whooping and hollering, after Aroldis Chapman recorded the 27th out. Suddenly, with reinforcements likely coming by Wednesday’s trade deadline and the schedule growing easier, the Yankees’ worldview seems nowhere as dire.

“The first three games didn’t go our way,” Didi Gregorius said, understating what went down, “so we needed a win.”

German, at 26 the youngest active member of the Yankees’ starting rotation, allowed three runs over 5 ⅓ innings, easily the best showing by his unit since J.A. Happ gave up two runs to the Rockies over five innings on July 19.

“I felt it was my responsibility to go out there and put a stop to [what has been] a rough patch for our starters,” the right-hander said through an interpreter.

Against Red Sox ace Chris Sale, a pair of Yankees two-run homers — by Austin Romine in the third and Gregorius in the fourth — gave the visitors the sort of cushion they hadn’t received the chance to develop previously. A trio of Red Sox errors and a few more timely hits by the Yankees, including an RBI double from the remarkable Gio Urshela, proved enough as the Red Sox never quite surrendered against German or the Yankees’ prime relievers.

As Romine said, when asked the feeling in the dugout after Gregorius’ shot to right field gave the Yankees a 4-0 edge, “Just keep going.”

And that’s what the Yankees will try to do. The middling Diamondbacks will be at Yankee Stadium for a quick, two-game visit Tuesday and Wednesday, off days sandwiching the miniseries, and by the time the Diamondbacks pack up their belongings late Wednesday afternoon, which just happens to be the trade deadline, you’d sure think the Yankees will have themselves another pitcher or two courtesy of Brian Cashman. And after the Red Sox’s four-game trip to the Bronx next weekend comes a 10-game oasis featuring the division’s cellar-dwellers: three at the Orioles, four at the Blue Jays and three more at home with the O’s.

All won’t fully be well until the Yankees start getting consistently acceptable starts. Yet on a day that began with CC Sabathia going on the injured list thanks to his achy right knee acting up again — and no prognosis on his return — and interesting trade target Marcus Stroman going from the Blue Jays to the Mets, of all places, they’ll gladly accept this baby step.

“Obviously that’s a happy room to finish off what in many ways was a difficult week,” Aaron Boone said. Referencing Minneapolis, where the Yankees battled to a 2-1 series victory despite terrible pitching, and Boston as “two tough places,” the manager saw the silver lining to “at least go back with three wins in the pocket.”

The third win meant the most. “It’s good that we ended on a good note so we can come back on the same good note and just keep going,” Gregorius said.

If they keep going like this, then they should be ready to go come October.