Masahiro Tanaka pitcher for the NY Yankees pitching against the...

Masahiro Tanaka pitcher for the NY Yankees pitching against the Boston Red Sox on Saturday, Sept. 2, 2017 at Yankee Stadium. Credit: Errol Anderson

Once again, it was the Masahiro Tanaka of the previous three seasons, when the righthander was the unquestioned staff ace.

And it couldn’t be happening at a better time for the Yankees.

Backed by a tiebreaking three-run homer by Matt Holliday, Tanaka pitched another gem Saturday afternoon in a 5-1 victory over the Red Sox in front of a sellout crowd of 46,536 at the Stadium.

“He was the Tanaka that we’re used to seeing,” said Chase Headley, who went 3-for-4, including a second-inning homer that gave Tanaka a 1-0 lead.

The victory pulled the Yankees (72-63) within 4 ½ games of the AL East-leading Red Sox (77-59). Sunday night’s game — with Luis Severino opposing Boston’s Chris Sale — will be the finale in their season series, which the Yankees lead 10-8.

“That’s the goal [winning the AL East title] that we’re focused on,” Headley said. “We certainly aren’t focused on anything but winning the division.”

Tanaka (11-10, 4.54 ERA) allowed one run and five hits in seven innings-plus, walking two and striking out three. If he continues to resemble the pitcher who went 39-16 with a 3.12 ERA in his first three seasons with the Yankees, it will give them a fighting chance.

Though Tanaka entered the day with pedestrian season numbers — 10-10 with a 4.69 ERA — that obscures his turnaround from a mostly dreadful first half. He is 6-3 with a 2.77 ERA in his last 12 starts. In his last six starts, he has been even better, going 4-1 with a 2.08 ERA, a 0.92 WHIP and 40 strikeouts in 39 innings.

“It’s been really important,” Joe Girardi said. “He’s the guy that’s led our staff the last few years, and we needed to get him back, and he’s back on track and throwing the ball really well.”

Though the turnaround started well before that, Tanaka said the 12 days he spent on the disabled list from Aug. 10-21 with right shoulder inflammation was a benefit. In three starts since returning, he has allowed five earned runs in 21 innings for a 2.14 ERA.

“I really think that was the right move,” Tanaka said through his translator. “I was able to get some time to refresh the arm as well as have time to strengthen the arm, so the arm does feel stronger.”

The Yankees, who had 10 hits after managing only four the night before, brought a 1-0 lead into the sixth, but Eduardo Nuñez doubled off the leftfield wall, advanced on Andrew Benintendi’s grounder and scored on a wild pitch. Tanaka’s slider in the dirt bounced off Gary Sanchez’s chest protector and away from the plate, and Nuñez easily beat Sanchez’s toss to Tanaka.

Didi Gregorius worked a leadoff walk in the bottom of the sixth and Headley picked up his third hit with a line-drive single to center. Then lefthander Drew Pomeranz (14-5, 3.36 ERA) delivered a dead-straight 92-mph first-pitch fastball to Holliday, who blasted a long three-run homer into the bleachers in leftfield to make it 4-1.

Jacoby Ellsbury tripled and sored on Sanchez’s single in the seventh for a 5-1 lead. Sanchez had three hits and threw out Rafael Devers trying to steal second in the fifth.

Holliday was activated off the disabled list Friday and saw his first action Saturday. In his previous 23 games beginning June 22, he had a .120/.155/.174 slash line. The home run was his 17th of the season and first since July 15, when he hit a tying homer in the ninth off Craig Kimbrel in the Yankees’ 16-inning victory.

“It’s huge to have him back,” Tanaka said.

Same goes from the Yankees’ perspective of having the Tanaka of old.

More Yankees headlines

Newsday LogoYour Island. Your Community. Your News.Digital AccessOnly 25¢for 5 months