Max Fried of the New York Yankees against the Detroit...

Max Fried of the New York Yankees against the Detroit Tigers at Comerica Park on Wednesday. Credit: Getty Images/Nic Antaya

DETROIT – Max Fried was as good as he’s been in his brief time as a Yankee, maybe as good as he’s been in his nine-year career.

Devin Williams nearly shoved that to the backburner with another shaky out, almost blowing the entirety of a four-run lead, but the Yankees hung on to beat the Tigers, 4-3, on a 42-degree afternoon at Comerica Park to avoid a three-game sweep and snap a three-game losing streak.

“Still figuring stuff out,” said Williams, who took the mound with a 4-0 lead but needed Mark Leiter Jr. to record the final out, with a runner on second, to preserve the win.

Ben Rice’s two-out, two-run homer in the seventh broke a scoreless tie and snapped the Yankees’ 16 2/3 innings streak this series without a run and put Fried in position to pick up the victory, which improved the lefthander to 2-1 with a 1.56 ERA after he allowed five hits over seven scoreless innings. He struck out 11, two short of his career high.

“Wow, that was just incredible by him,” said Aaron Judge, whose two-run single in the ninth gave the Yankees (7-5) the 4-0 cushion, every bit of which was needed. “Especially coming out, we lose the first two games of the series, kind of down, offense wasn’t really getting much going. For him to come out there and give us some strong innings, some big outs … that was really impressive.”

Fried (2-0, 1.56) needed to be impressive because the opposing pitcher, Jack Flaherty, a high school teammate of Fried’s at Harvard-Westlake School in Los Angeles, was just as good.

Flaherty, whom the Yankees nearly had a deal for at last year’s trade deadline before pulling out of it because of concerns with the pitcher’s medicals, allowed three hits and three walks over 5 1/3 scoreless innings in which he struck out nine. The righthander did not last as long as Fried because of the second inning, one in which the Yankees did not score after loading the bases with two outs but an inning in which they forced him to throw 36 pitches, bumping his pitch total to 47.

“I’m facing the lineup so I’m not necessarily facing him,” Fried said of Flaherty. “But you know he’s a really good pitcher and you have to be on your game.”

Williams allowed two walks and a hit to load the bases in the ninth. He threw a wild pitch with Zack McKinstry at the plate to make it 4-1 and put runners at second and third. McKinstry’s two-run single to right made it 4-3 and the outfielder took second on Judge’s throw to the plate. Aaron Boone brought in righty Mark Leiter Jr., who retired Justyn-Henry Malloy on a pop out that second baseman Jazz Chisholm Jr. caught on the outfield grass, for the save.

“Haven’t felt like 100% myself up until this point,” said Williams, who made clear he wasn’t talking about physically. “Physically, I’m fine. I just need game reps, things like that. (I’m not) executing pitches, getting ahead in counts, not doing that. This isn’t the first season I’ve started a season off on the wrong foot. All you can do is keep working.”

Fried, brilliantly mixing his extensive pitch arsenal, struck out 11 over seven innings in which he allowed five hits.

When Williams left the bullpen, Leiter wasn’t necessarily expecting to be called on for a save situation but the veteran righty was ready.

“Devin’s the best closer in the league, no question about it,” Leiter said. “Just coming in with a chance to pick him up, as he’s going to pick us up all year. The job at the end of the day is to go win the game.”

Rice’s homer, his third of the year, gave Fried the lead. The pitcher, after allowing a leadoff double in the bottom of the seventh, quickly retired three straight, striking out the last two batters he faced.

“It felt huge,” Rice, who is hitting .306 with a 1.086 OPS, said of his blast. “Max was battling for us the whole game, kept us in it in a pitcher’s duel there early. Gave us a chance to come back in the later innings and put some runs on the board, so to come through on that was massive.”

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 6 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME