The Yankees' Domingo German pitches during the first inning against the...

The Yankees' Domingo German pitches during the first inning against the Red Sox in Boston on Sunday. Credit: AP / Michael Dwyer

BOSTON — Domingo German wasn’t quite his ace-like self from the early part of the season, but the Yankees and their beaten-up rotation didn’t require that Sunday night. A good outing — or even a decent one — would suffice, and German gave them a combination of the two against the Red Sox at Fenway Park.

German allowed three runs, four hits and a walk in 5 1⁄3 innings — marking the longest outing by a Yankees starter since Masahiro Tanaka lasted six innings July 20 — as the Yankees beat Boston, 9-6.

“I felt it was my responsibility to go out there and put a stop to it,’’ German (13-2) said through his translator. “It’s been a rough patch for us starters. Tonight I felt I needed to go out there and do my job.”

German, who departed with a 6-3 lead, featured a mostly filthy curveball that helped him strike out nine, tying his season high.

“Great poise,’’ Aaron Boone said. “A game we really wanted, he came out and completely set the tone and delivered the goods for us tonight.”

In the first three games of this series, the Red Sox totaled 38 runs and 52 hits, including 33 for extra bases.

Salvaging the finale of the four-game series leaves the AL East-leading Yankees 8 1⁄2 games ahead of the Rays and nine ahead of Boston. They lead both by 10 games in the loss column.

“Obviously, that’s a happy room,” Boone said in his cramped office as music from the adjoining visitor’s clubhouse boomed through the walls. “To finish off what in a lot of ways was a difficult week for us . . . This was a good one, no doubt.”

The numbers for the rotation in the last week-plus were almost hard to comprehend. The group, which general manager Brian Cashman is feverishly trying to upgrade before Wednesday’s trade deadline, had a 17.67 ERA and 2.74 WHIP in its last 27 innings, allowing 57 runs (53 earned), 61 hits (including 19 homers) and 13 walks.

In his previous outing Tuesday in Minneapolis, German allowed a career-high eight earned runs in 3 2⁄3 innings. The primary issue that night, one in which German gave up three home runs, was his curveball arriving in the strike zone invitingly flat. But it was far from flat Sunday. He struck out six in three innings and seven through four.

“It was the most calm I’ve seen him, the most collected I’ve seen him,” said Austin Romine, whose two-run homer off Chris Sale (5-10, 4.26) in the third made it 2-0. “I think he was on a mission. He was throwing so many good pitches. Much needed.”

Didi Gregorius gave the Yankees a 4-0 lead in the fourth with a two-run homer that gave him 20 RBIs in his last 12 games and 15 hits in his last 37 at-bats.

German’s biggest mistake was a hanging curve to Andrew Benintendi, whose two-run homer in the bottom of the fourth brought Boston within 4-2.

In the sixth, Gio Urshela hit a rocket to center for an RBI double that made it 5-2 and knocked out Sale. Urshela went 2-for-4 with two doubles to complete a stellar trip in which he went 10-for-23 with six doubles, two homers and four RBIs. Cameron Maybin greeted Colten Brewer with a single to make it 6-2.

The Yankees got two unearned runs in the seventh. Jackie Bradley Jr. made a running catch for the second out but threw to an unoccupied first base in an attempt to double off Luke Voit. The ball carried into the Red Sox dugout, bringing in two runs to make it 8-3. Maybin doubled and scored on a wild pitch in the eighth for a 9-4 lead.

The Red Sox loaded the bases with one out in the eighth, but Zack Britton struck out Bradley and got Christian Vazquez to ground into a forceout. Benintendi had a two-out, two-run single off Aroldis Chapman in the ninth, but Chapman struck out Michael Chavis to end it.

“We have to do better, certainly, than we have this week,” Boone said of the rotation. “But also confident in those guys that we will do better and that this was a bad week. But for Domingo to go out and do it, I’m not surprised. I’m not surprised that moment for him was not too big.”

More on this topic

More Yankees headlines

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 5 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME