NEW YORK —

Baltimore, which clinched a postseason berth by winning Tuesday night’s opener of the three-game series, will be in a best-of-three wild-card series starting Tuesday.

Stanton homered in the second to put the Yankees ahead and hit a three-run double in a six-run sixth.

Judge hit a two-run homer in the seventh against Bryan Baker and has 144 RBIs, the most in the major leagues since Ryan Howard’s 146 in 2008. Judge matched his career best by homering in five consecutive games.

Making his last start before the playoffs, Cole (8-5) allowed two hits in 6⅔ innings, struck out five and walked one, lowering his ERA to 3.41. He struck out Anthony Santander with a 98.1 mph fastball that ended the eighth after plate umpire David Rackley called a ball on the previous pitch, a knuckle-curve that appeared to be just above the strike zone. Cole glared at the umpire as the pitcher walked back to the dugout.

Cole was given a standing ovation when he walked to the dugout with two outs in the seventh and tipped his cap to the crowd of 42,022.

Burnes (15-9) allowed two hits in five innings, one walk and nine strikeouts — including eight on cutters. Burnes came out after 69 pitches and is likely to start the Orioles’ postseason opener Tuesday. He had a 1.20 ERA in five September starts.

Stanton lofted a slider at the bottom of the strike zone into the left-field seats after missing badly at a slider on the prior pitch.

Austin Wells, in a 4-for-42 slide, forced in a run when he walked with the bases loaded against Cionel Pérez. Stanton drove the next pitch on one hop to the wall in right-center for a 5-1 lead. Stanton has 72 RBI after hitting 6-for-18 with 2 doubles, 2 homers and 8 RBIs in his past five games.

Anthony Rizzo added a two-run single against Baker.

Emmanuel Rivera hit a ninth-inning sacrifice fly for the Orioles.