Juan Soto of the Yankees celebrates his 10th-inning walk-off base hit...

Juan Soto of the Yankees celebrates his 10th-inning walk-off base hit against the Boston Red Sox at Yankee Stadium on Thursday. Credit: Jim McIsaac

The Yankees sure needed that.

Of course, at this point of the season, they pretty much need them all.

One night after their offense struggled in an eventual victory in 11 innings over the Royals, the Yankees went extras again Thursday night against the Red Sox.

They needed 10 innings this time but again came away with the victory, winning 2-1 on Juan Soto’s walk-off single to center leading off the bottom of the 10th to send a Stadium crowd of 40,229 home happy.

“It was a fun to way to finish the game,” Soto said after his first walk-off hit as a Yankee.

The Yankees (85-62), whose one run before the 10th came on Gleyber Torres’ leadoff homer in the first, upped their lead over the idle Orioles to two games in the American League East.

“Guys are playing really well,” Aaron Boone said. “Haven’t had a lot of offense necessarily the last few nights, but doing enough.”

Aaron Judge, who went 1-for-4, had his homerless streak extended to 16 games – spanning 71 at-bats – which is a new career high.

“He probably needs to get thrown out again by an umpire,” Nestor Cortes said of Judge’s first career ejection, which came on May 4 at the hands of Ryan Blakney and, coincidentally, was about the starting point for the four-plus month tear the centerfielder went on. “On a serious note, Judge is going to come on again and be the guy for us.”

And, despite the homerless streak, Judge came into the night getting on base at a .358 clip during this “slump,” including three times Wednesday night (he went 1-for-4 on Thursday).

Jon Berti, who pinch ran for Torres as the extra-innings ghost runner and scored the game-winner Wednesday, was part of a similar script Thursday, coming in on Soto’s ground smash up the middle on a 2-and-2 sinker from righthander Josh Winckowski.

“Definitely tried to drive the ball to the middle,” Soto said. “Whenever I get to two strikes, I change my approach to try to pull the ball a little bit to make sure the guy gets over. I definitely found a hole.”

Clay Holmes, who blew his MLB-leading 12th save Wednesday and who last week was demoted from closer, stranded a runner at second in the top of the 10th, retiring two straight after taking over for Tommy Kahnle. Holmes, who took the mound to a mixture of cheers and also boos, left the mound to all cheers.

“We all know what kind of stuff he has,” Soto said of Holmes.

Cortes recalled a recent conversation he had with backup catcher Jose Trevino regarding Holmes, a free agent after the season.

“Me and Trevi talked about it last week: when we’re going to need Clay the most, he’s going to come through for us, whether it’s the seventh, whether it’s the eighth, whether it’s the ninth, whether it’s an extra-inning game,” Cortes said. “Clay has it in him.”

Said Holmes: “Some special guys in this clubhouse. And that’s why I play. I enjoy competing with them and being on the field with them and, really, when I’m out there I want to do my best for these guys. It’s always a fun atmosphere to play in.”

It was part of an overall strong night from the bullpen as Ian Hamilton, Tim Hill, Kahnle and Holmes went unscored on.

Cortes, inserted back into the rotation after a detour last Saturday to the bullpen, allowed one run and three hits over five innings in which he struck out nine to match a season high. Cortes, in relief of Clarke Schmidt at Wrigley Field against the Cubs, did not allow a hit over 4 1/3 scoreless innings.

“I’m just trying to go out there and throw as many zeros as I can,” Cortes said. “I know last week I might have come off like I was asking for too much, but I got my point across. And at the end of the day, I’m going to do whatever this team needs for me to do to win, whether it’s throwing 40 pitches out of the ‘pen or 70 pitches out of the ‘pen or starting a full game. All we want to do is win ballgames and get to October.”

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 5 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME