Aaron Judge of the Yankees celebrates his first-inning home run against the...

Aaron Judge of the Yankees celebrates his first-inning home run against the Detroit Tigers at Yankee Stadium on Thursday. Credit: Jim McIsaac

The Yankees were aware of what it meant to play at home on the 24th anniversary of the 9/11 attacks. They were aware of how rare it was to be visited by a sitting President, as they were in their clubhouse before Thursday night’s game by Donald Trump.

But what the Yankees were most aware of was that they had been embarrassed by the Tigers the previous two nights in a pair of ugly losses. They needed a win. And they got one.

Aaron Judge homered twice to tie Joe DiMaggio for fourth place on the franchise list in a 9-3 win over Detroit before 40,608 on an emotional night  at Yankee Stadium.

“That was a good win,” manager Aaron Boone said. “All in all, a good day.”

The Yankees, who remained three games behind first-place Toronto in the AL East, had lost the previous two games by a combined score of 23-3.

“It was an awesome night,” Boone said. “Meaningful. [Judge] just spoke about it. Just having us out there, kind of all lined up together, first for the moment of silence, then back out there for the anthem and just that buzz that New York City can create. You definitely felt it tonight. Obviously, the President being here, just an added layer. A special night to be a part of. And hopefully none of us took it for granted.”

Judge walloped solo homers in the first and third innings to give him 46 this season and 361 in his career. On Tuesday, he passed Yogi Berra for fifth with No. 359. Soon he’ll pass DiMaggio.

“Joe DiMaggio,” Boone said. “I mean, Joe DiMaggio.”

Judge’s first home run off lefthanded opener Tyler Holton came on a 3-and-2 pitch and traveled 413 feet into the Tigers’ bullpen in left-centerfield. It gave the Yankees a 1-0 lead.

Judge’s second home run off righthander Sawyer Gipson-Long came on a 1-and-0 pitch, traveled 434 feet into the Tigers’ bullpen and gave him 100 RBIs. Giancarlo Stanton followed two batters later with a 429-foot solo home run into the leftfield bleachers for a 5-1 lead.

The Yankees added four runs in the fourth on RBI singles by Austin Slater and Cody Bellinger and a two-run single by Jazz Chisholm Jr. to make it 9-1.

The homers by Judge (3-for-4, hit by pitch) came on a night the Yankees commemorated the 24th anniversary of the 9/11 attacks with a pregame ceremony. Security lines were long outside the stadium as TSA personnel and Secret Service officers screened fans on the way in because of Trump’s presence.

"We put on a show," Judge said. "He came in here and told us we were going to win. I think that gave everybody the confidence in the room to go out there and do it. I guess we've got to have him around more often."

Trump, who sat in a third-base luxury box with Yankees owner Hal Steinbrenner and team president Randy Levine and left in the eighth inning, met with most of the Yankees players in their clubhouse before the game and teased Judge about his prowess.

After shaking hands with the Yankees’ captain and slapping him enthusiastically on his injured right elbow, Trump said: “You have that much muscle, you have to hit the ball perfect. Fantastic player. Unbelievable player.”

“I appreciate that,” Judge said.

Babe Ruth is the Yankees’ all-time leader with 659 of his 714 home runs as a Yankee. He is followed by Mickey Mantle (536) and Lou Gehrig (493), both of whom (like Judge and DiMaggio) played only for the Yankees.

"Just two legends," Judge said of Berra and DiMaggio. "Greats in the game. Great all-time Yankees. Pretty cool to be on a list with them. Pretty cool getting the win."

Cam Schlittler (3-3, 3.05 ERA) rebounded from a career-worst 1 2⁄3-inning outing by allowing one run in six innings.

Jose Caballero, starting his second straight game in place of injured shortstop Anthony Volpe, went 2-for-3 with an RBI, a walk and two stolen bases.

Volpe had a cortisone shot on Wednesday because of what the Yankees revealed is a partially torn labrum in his left shoulder that they have known about since he injured the shoulder in May. Boone said Volpe aggravated the injury Sunday.

Boone said Volpe could return as early as this weekend in Boston, but the manager would not commit to Volpe getting his starting job back.

“It’s kind of all hands on deck,” he said, “and [we’ll] do what we think is best day in, day out.”

Notes & quotes: The Yankees (81-65) moved a half-game ahead of the Red Sox (81-66), whom they will face in a three-game series at Fenway Park this weekend . . . The Yankees are 5-4 in this 12-game stretch against division leaders Houston, Toronto and Detroit and wild-card contender Boston . . . Judge reached 361 homers in 10 years and 1,129 games. DiMaggio did it in 13 years and 1,736 games and Berra reached 358 in 18 years and 2,116 games. DiMaggio is revered for hitting almost as many homers as he had strikeouts (369). Judge, by comparison, has struck out 1,358 times. (Berra had 411 strikeouts.)

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 6 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME