Masahiro Tanaka of the Yankees reacts after giving up a...

Masahiro Tanaka of the Yankees reacts after giving up a two-run home run to Mookie Betts of the Red Sox in the third inning against the Boston Red Sox at Fenway Park. Credit: Getty Images / Adam Glanzman

BOSTON — CC Sabathia’s performance earlier in the day made Sunday’s nightcap a gravy game of sorts. At worst, the Yankees, in a horrific slump before the All-Star break that continued with a crushing walk-off loss Friday night, would leave Fenway Park with a split of the four-game series against the AL East-leading Red Sox.

And Boston lefthander David Price made sure that was the case, doing something he hasn’t done in some time against the Yankees. He shut them down, going eight innings and handing them a 3-0 loss in Game 2 of the doubleheader. The Yankees, who won the first game, 3-0, behind CC Sabathia, entered Game 2 as the only MLB team not to have been shut out this year.

The series split left the Yankees (47-43) where they were at the All-Star break: 3 ½ games behind Boston (52-41) and two games out in the loss column. “We probably gave one away and we probably also stole one,” Joe Girardi said of a series in which elite closers Aroldis Chapman and Craig Kimbrel blew save chances in the first two games. “I thought we played pretty well, I thought we pitched pretty well. Our bullpen did a tremendous job. It’s a tough place to play and we ended up 2-2. We’re going in the right direction, and I think part of that was getting our bullpen back on track.”

As good as Price was, he was the beneficiary of an incredible defensive play in the eighth. With a runner on, centerfielder Jackie Bradley Jr. robbed Aaron Judge of his 31st home run with a leaping catch in the triangle near the 420-foot sign, prompting Price to break into a huge smile.

Said Judge, “Just hit it to the wrong part of the ballpark to the wrong centerfielder.”

Price, who had an 8.31 ERA in six previous starts against the Yankees as a member of the Red Sox, allowed seven hits and no walks in improving to 4-2, 3.39. He struck out eight.

Kimbrel, who blew the save Saturday when he gave up Matt Holliday’s ninth-inning home run in an eventual 16-inning victory by the Yankees, picked up his 24th save with a scoreless ninth. After Didi Gregorius doubled with one out and Brett Gardner walked with two outs to bring the tying run to the plate, Chase Headley struck out.

Masahiro Tanaka (7-9) allowed three runs, eight hits and no walks in seven innings, striking out nine. Mookie Betts’ two-run homer in the third made it 2-0 and snapped a 24-inning scoreless stretch for the Red Sox in which they had only nine hits.

“Overall I felt pretty good. The stuff was there,” Tanaka said through his translator. “The one hanging slider, I’d take that back, but you can’t. Price pitched a hell of a game, too.”

Sabathia pitched six innings in Game 1 as the Yankees earned consecutive victories for the first time since June 11-12. The 37-year-old lefthander battled control issues, walking five, but allowed only two hits in improving to 8-3 with a 3.54 ERA.

The Yankees had 12 hits in the first game, getting two each from Headley, Gregorius, Clint Frazier, Ji-Man Choi and Ronald Torreyes. Frazier reached on an error in the fourth, leading to two unearned runs. Choi’s sacrifice fly and Torreyes’ RBI single made it 2-0, and Gregorius added his 11th homer in the fifth.

While it was hard to criticize the Yankees for earning a split on the road against the division leader, some issues cropped up that are worth watching.

An often-criticized bullpen did much to right the ship, but the Yankees mostly struggled at the plate in the four games, scoring 11 runs in 43 innings. Judge went 1-for-18, with his only hit a soft infield single.

Then again, to be fair, it’s not as if the Yankees faced a run of mediocre pitchers, other than reigning AL Cy Young Award winner Rick Porcello (4-12, 4.60) in Game 1. There was Drew Pomeranz on Friday night, the dominant Chris Sale on Saturday and former AL Cy Young Award winner Price last night.

In Game 1, the Red Sox had a runner on third with less than two out in each of the first two innings, but the Yankees turned a double play in the first and Sabathia made a nice play on a comebacker in the second, getting the out at the plate.

Sabathia initially was slated to start Monday night in Minnesota but was told late Saturday that he would take the ball in place of Bryan Mitchell, who now will start the opener against the Twins. “I’ve pitched against these guys so much, we pretty much have a game plan, so we just moved it up a day,” said Sabathia, who unsuccessfully lobbied Girardi to let him go back out for the seventh. “I felt good. I hadn’t pitched in a long time, so I wanted to get back out there.”

Referring to rebounding after Friday night’s blown save by Chapman, he said, “Just shows you a lot about this team, how tough we are. Obviously, we struggled the last two weeks before the break, tough loss on Friday night, but to be able to come back and battle last night and come out todayfeels good. The core of this team are tough guys. We leave everything on the field every night and it shows up.”

The series certainly could have gone worse for the Yankees, especially after their walk-off loss Friday night, but Judge wasn’t satisfied with the split. “Not good,” he said. “We want to come out, especially with Boston in first place, and try to shorten that lead a little bit. But we came out 2-2 and now we go on to Minnesota and try to keep winning.”

More Yankees headlines