MINNEAPOLIS — If only the Yankees could play the Twins every step of the way.

While the Yankees didn’t punish their favorite punching bag Monday night in Game 3 of the ALDS, they swept the Twins in three games with a 5-1 victory that was witnessed by a sold-out crowd of 41,121 that included Hal Steinbrenner.

The victory advanced the Yankees to the ALCS for the second time in three years. They will play the Astros or Rays in the best-of-seven affair. The Astros lead that series, 2-1, with Game 4 Tuesday night in St. Petersburg, Fla. No matter the opponent, the ALCS opens Saturday. If it is Yankees-Astros, Game 1 will be in Houston. If it’s Rays-Yankees, Game 1 will be in The Bronx.

It was the Yankees’ 13th straight postseason win over the Twins, who have lost 16 of 18 postseason games to the Yankees.

Gleyber Torres went 3-for-4 with a homer and Cameron Maybin, who entered the game as a defensive replacement for left fielder Giancarlo Stanton in the seventh inning, led off the ninth with a towering homer to left off Sergio Romo that upped the Yankees’ lead to 4-1. Didi Gregorius added an RBI single later in the inning for the final run.

Luis Severino danced in and out of trouble in three of the four innings he worked but didn’t allow a run. Tommy Kahnle worked two-thirds of an inning in which the Twins didn’t score.

Adam Ottavino walked the only batter he faced (Nelson Cruz) and was replaced by Chad Green. Thanks to Torres and DJ LeMahieu combining to rob Eddie Rosario of hit in the fifth that would have scored a run, Green stranded two. He then worked around a one-out double by Luis Arraez in the sixth, but exited when pinch-hitter C.J. Cron opened the seventh with a single.

Zach Britton entered and retired Max Kepler on a fly to right and a grounder to the right side that forced Britton to cover first as Cron went to second. Britton got Cruz to bounce back to him for the inning’s final out.

Rosario opened the eighth inning with a homer to center off Britton, who retired Mitch Garver on a grounder to short and left the game with trainer Steve Donohue. Britton appeared to bang his right leg against Jorge Polanco’s leg covering first base for the second out in the seventh and looked to land awkwardly on the bag.

Aroldis Chapman replaced Britton and watched Luis Arraez’ liner to right find Aaron Judge’s glove for the second out and Miguel Sano strike out on a 100 mph fastball.

Chapman wiggled out of trouble in the ninth after Marwin Gonzalez opened the inning with a single to center and Cron drew a walk. Chapman struck out Max Kepler, who finished the series 0-for-10, then got some help from Gregorius, who made a diving stab of a liner off the bat of Jorge Polanco for the second out. Chapman struck out Cruz looking to end it.

Gregorius’ single to right with one out in the seventh scored Torres from second and upped the Yankees’ lead to 3-0.

After Green stranded two runners in the fifth, Green gave up an opposite-field, one-out double to left to Arraez in the sixth.

Miguel Sano took a 3-2 pitch to right that Judge jumped for in front of the warning track for the second out. For a heartbeat Marwin Gonzalez’s fly ball to right appeared to have enough to get out and tie the score, 2-2. Then Judge settled under it in front of the track for the third out and the 2-0 Yankees lead was intact.