BOSTON — Both pitchers knew what they were up against Thursday night at Fenway Park.

And when it was over, Masahiro Tanaka outdueled Chris Sale in a battle of aces.

“I enjoy the competition,” Tanaka, speaking through an interpreter, said after spinning a three-hitter to lead the New York Yankees to a 3-0 win over Sale’s Red Sox and a sweep of what turned out to be a two-game series because of a Tuesday rainout.

“I think a lot of people thought about how well he was pitching up to this point and that Chris Sale had the upper hand,” Tanaka said. “I wanted to go in there and try to beat the odds, I guess.”

Tanaka (3-1) became the first Yankee to shut out the Red Sox since Mike Mussina did it in 2002. He needed just 96 pitches to win his third consecutive start.

Tanaka threw the fifth complete game of his career and his first since 2015. He didn’t walk anyone and struck out three in raising his career record to 42-17, 6-2 against the Red Sox.

The battles of aces took 2:21, the shortest game between the rivals in 23 years.

Tanaka retired the last 14 batters, good for 15 outs, and needed 97 pitches to complete his second career shutout — the first by a Yankee in almost three years.

“That’s tough,” an impressed Sale said. “Complete game’s tough. Shutout’s tough. Under a (hundred pitches), that’s being pretty darn good. You gotta tip your cap. He’s as tough as anybody when he’s throwing like that.

“The moral of the story is I just got flat-out outpitched. That’s it.”

The Yankees, who started the season 1-4, are 12-3 since. A sweep at Fenway of any length is always nice.

“It’s only two games. Should give our guys some confidence though,” Yankees manager Joe Girardi said.

New York third baseman Chase Headley said, “We are playing good baseball and are confident right now. We came in and beat two of their better pitchers (Rick Porcello on Wednesday) in a way that is not the norm for us (low scoring).”

Sale, acquired in a big offseason trade of major Boston prospects, continued to be the victim of non-support. He held the game close until the Yankees scored two in the ninth, but he fell to 1-2 with a 1.19 ERA.

Sale wound up charged with three runs (two earned) on eight hits with 10 strikeouts and no walks in eight-plus innings. It was his fourth straight double-digit strikeout game, making him the fourth Red Sox pitcher since 1913 to amass such a streak.

Matt Holliday’s sacrifice fly in the fourth inning was enough to beat Sale, who has received a total of four runs of offense while on the mound for his five Red Sox starts.

Sale’s 52 strikeouts in five starts are the second most by a pitcher with a new team (since 1913). He is 4-2 with a 1.31 ERA against the Yankees in 11 career games (eight starts).

Sale allowed three straight singles to start the ninth, with Holliday bringing home a run. Starlin Castro greeted reliever Heath Hembree with an RBI single.

“The only frustration is towards myself,” Sale said. “I know what I can do, and I just gotta to be better than that, flat out gotta be better in that last inning.

“We had a chance there in the ninth, and I just completely took the wind out of our sail on us. That’s unacceptable. I gotta be better than that. No doubt.”

Hanley Ramirez had two singles and was the only Red Sox runner to reach second base as the slumping Boston bats continued to flounder. Boston (11-10) scored one run in the past two games and has scored 13 in the past seven. The Red Sox have been shut out in three of those seven games.

Tanaka went out for the ninth with Yankees closer Aroldis Chapman, who threw 36 pitches in a shaky save the previous night, warming up. Three groundouts and it was over.

“He talked before the game about the challenge of facing Sale,” Yankees pitching coach Larry Rothschild said. “He’s a pitcher that can perform at a high level, and that’s what he did.”

NOTES: SS Didi Gregorius, who sustained a right shoulder injury at the World Baseball Classic, will return to the Yankees’ lineup Friday night after missing the first 20 games of the season, while C Gary Sanchez (biceps) begins a rehab in Triple-A on Monday. … Boston claimed UT Chase d’Arnaud off waivers from the Atlanta Braves and moved RHP Carson Smith from the 10- to the 60-day disabled list after he experienced a setback in his rehab from Tommy John surgery. The Red Sox sent OF Steve Selsky to the minors after the game. … LHP CC Sabathia faces Baltimore in New York’s opener of a home three-game series with the Orioles on Friday night, while LHP Drew Pomeranz goes for Boston to open a three-game home interleague series with the Chicago Cubs.