Trent Grisham of the Yankees celebrates his sixth-inning three-run home run against...

Trent Grisham of the Yankees celebrates his sixth-inning three-run home run against the Dodgers with teammate Aaron Judge at Yankee Stadium on Sunday. Credit: Jim McIsaac

As Trent Grisham faced Dodgers righthander Tyler Glasnow with the Yankees down a run in the sixth inning on Sunday night, Yankees fans started chanting.

Not for Grisham . . . but for Grisham to be pinch hit for by the injured Juan Soto.

“We want Soto! We want Soto!”

They didn’t get Soto. What they got instead was a go-ahead three-run homer to right by Grisham. The Yankees went on to salvage the series finale with a 6-4 victory before a sellout crowd of 48,023 at Yankee Stadium.

The fans’ wish was reasonable; expressing it in that way was a bit rude. But in an “only in New York” sort of way, it worked out.

Grisham was a surprise No. 5 hitter in the Yankees’ Soto-less lineup. He entered the at-bat hitting .082.

The Yankees were trailing 3-2 when Grisham parked his third home run of the season into the lower deck in right. It was his fifth hit of the season in his 50th at-bat, raising his average to .100.

The soft-spoken Grisham, asked if he heard the Soto chants, said with a smile: “Yes, I heard it.”

He added: “It wasn’t about that. I was just happy that I was able to stay present in the moment, worry about myself and ended up putting a good swing on one.”

“I wasn’t too happy with it,” Aaron Judge said. “But I think he made a good point, got his point across there with that homer.”

Some fans — certainly not as many as before — chanted “we want Grisham” when the centerfielder came up the next time in the eighth and walked.

“Yeah, I heard them coming up the next time,” Grisham said. “I liked those, too.”

Said manager Aaron Boone, “It’s just part of the great environment that was out there this weekend and this game tonight, for sure. I heard the “we want Grisham’’ the next time around. I didn’t get too involved with it. I certainly heard it.”

Judge (3-for-4, two RBIs) added his MLB-leading 24th home run, a 434-foot solo shot inside the foul pole and into the second deck in left in the eighth.

In the last 32 games, Judge has 18 home runs, 40 RBIs, a .418/.542/1.055 slash line and a 1.597 OPS.

Judge, who went deep twice on Saturday, has seven home runs in his last 10 games and 20 in his last 40.

The Yankees took their first lead of the three-game series when Oswaldo Cabrera homered off the foul side of the rightfield foul pole in the third. It was his fifth home run. He was in the lineup at third base as Boone sat down Anthony Rizzo and started DJ LeMahieu at first.

Later in the inning, Alex Verdugo and Judge hit back-to-back two-out doubles to give the Yankees a 2-0 lead. Judge’s double went off the glove of a leaping Andy Pages at the right-centerfield wall.

Luis Gil, who came in with an 8-1 record and 1.82 ERA, held the Dodgers to one hit in the first four innings. The Dodgers got to him in the fifth on Mookie Betts’ tying two-out, two-run double.

Teoscar Hernandez, who had two homers (including a grand slam) and six RBIs in the Dodgers’ 11-3 victory on Saturday, gave Los Angeles a 3-2 lead in the sixth with his 16th home run.

That was it for Gil, who allowed three runs in 5 2⁄3 innings with one walk and five strikeouts. He had given up one or zero runs in each of his previous seven starts. Of the five hits allowed by the rookie, three were doubles and one was a home run.

Caleb Ferguson (1-3) replaced Gil and struck out Jason Heyward for the final out of the sixth. That put the lefthander in line for the win once Grisham gave the Yankees the lead.

Glasnow (6-5) struck out 12 in six innings but ended up taking the loss.

Clay Holmes worked around a pair of two-out singles in the ninth for his 19th save. Holmes struck out Betts for the final out to conclude the exciting series.

“That’s a playoff atmosphere,” Judge said. “Fans came to see two great teams do their thing . . . They were loud for both sides, Dodgers and Yankees. That was an atmosphere you want to play in.”

More Yankees headlines

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 5 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME