CHICAGO — Aroldis Chapman has blown saves before in his stellar career as a closer. But this one had to sting a bit more than the others.

But only for about three hours.

In a 6-hour, 5-minute game that ended at 2:14 a.m. EDT on Monday, the Yankees pushed across a run in the top of the 18th inning and beat the Cubs, 5-4, at Wrigley Field to sweep the three-game series.

A major league-record 48 batters struck out in the game (26 Cubs and 22 Yankees). The previous record was 43. A total of 583 pitches were thrown (294 by eight Cubs pitchers and 289 by seven Yankees pitchers). The teams combined to go 21-for-128.

“It’s a gritty performance by our guys,’’ Joe Girardi said. “Crazy game.”

Aaron Hicks led off the top of the 18th with a bunt single and advanced to second when the ball was thrown away by catcher Willson Contreras. “There was an opportunity there,’’ Hicks said. “Saw Kris Bryant playing back a little bit, so I felt like there was an opportunity to take a chance, and it worked out.”

advertisement | advertise on newsday

After Ronald Torreyes sacrificed Hicks to third, Starlin Castro grounded to short and Addison Russell — who supplanted Castro as the Cubs’ shortstop in 2015 — made a wide throw home as the go-ahead run scored.

The feeling as Hicks slid across the plate with the go-ahead run? “I’m excited,’’ he said. “Exhausted but excited.”

Chasen Shreve picked up the victory after pitching three innings of relief. With two outs in the bottom of the 18th, he walked Kris Bryant, and Girardi immediately ordered Anthony Rizzo to be intentionally walked. That brought pitcher Kyle Hendricks, pinch hitting for reliever Pedro Strop, to the plate, and Shreve struck out Hendricks — he of the .105/.139/.112 career slash line — to end the game.

The Yankees brought a 4-1 lead into the bottom of the ninth, thanks to Luis Severino’s stellar pitching, an RBI triple by Aaron Judge and a two-run homer by Jacoby Ellsbury. But former Cub Chapman — who received his World Series ring in a pregame ceremony on Friday afternoon — allowed three runs in the ninth and had to be rescued by Tyler Clippard.

Chapman walked Russell and allowed a single by Jon Jay to start the ninth. Contreras struck out, but pinch hitter Albert Almora Jr. and Javier Baez delivered RBI singles to make it 4-3. With Kyle Schwarber up, Baez stole second to put the winning run in scoring position, but Schwarber struck out for the second out. Bryant walked to load the bases and Chapman drilled Rizzo in the left forearm with his first pitch — a 100-mph fastball — to tie the score. Clippard then got Ben Zobrist to ground out to second to end the inning.

Yankees videos

“I felt normal,’’ Chapman said. “It just wasn’t my night tonight.”

The Cubs threatened in the 12th when Rizzo led off with a double and advanced to third on Almora’s long fly to left. But Adam Warren struck out Russell and got Contreras on a grounder to first.

For the Yankees, perhaps it’s time to stop discussing contention in terms of 2018, the target year set by many after last July’s sell-off.

The Yankees — who entered the night the AL leader in runs (162), homers (47) and slugging percentage (.475) — have the best record in the major leagues at 20-9 and have won 19 of their last 24 games, including three straight over the defending World Series champion Cubs.

“I think it is significant,’’ Girardi said. “It gives our guys even more confidence.”

advertisement | advertise on newsday

Chapman, of course, won a World Series with the Cubs last season. What does he see with the Yankees?

“The way the team is right now, it’s hitting, it’s playing good defense, it’s doing everything well,’’ he said. “It’s playing good baseball and the clubhouse is very united.”

Severino outpitched Jon Lester and flummoxed the Cubs in his seven innings. The 23-year-old righthander allowed one run, four hits and a walk and struck out nine, giving him 45 strikeouts and seven walks in 39 2⁄3 innings. The run came on a home run by Baez in the third that tied it at 1-1.

Lester, 13-6 with a 3.78 ERA against the Yankees, also was terrific, allowing two runs (one earned) and three hits in seven innings. He struck out nine and walked two.

After walking Hicks with two outs in the third, Lester retired 10 straight, six on strikeouts. That streak ended in the seventh when Castro hit a grounder to third that Bryant fielded but threw into the seats for a two-base error.

advertisement | advertise on newsday

That brought up Judge, 0-for-5 Saturday night and 0-for-2 to that point in the game. He crushed a full-count curveball to the base of the wall in centerfield for a none-out triple that made it 2-1. The Yankees stranded him, though, as Didi Gregorius popped up, Chase Headley grounded out and Austin Romine lined out.

After Brett Gardner batted for Severino and led off the eighth with a single, Ellsbury, starting in center for the first time since suffering a bruised nerve in his left elbow last Monday, hit a two-run homer off righty Justin Grimm to make it 4-1.

As they did Saturday night, the Yankees scored in the first.

Hicks walked with one out and Matt Holliday, getting his 10th career start at first base and first with the Yankees, singled. After a double steal — Joe Girardi indicated before the game that the Yankees might be a bit more aggressive against Lester, who famously doesn’t throw over to first because of the yips — Castro’s groundout made it 1-0.

Severino retired the first eight batters he faced before making a mistake with a 2-and-2 fastball that Baez hammered halfway up the bleachers in left for his fourth homer. Leftfielder Hicks didn’t appear to see the ball off the bat, holding his arms out wide and looking upward, never realizing where the ball was until it landed well behind him in the stands.