The Yankees opened wide Wednesday night and swallowed hard cash when they released Jacoby Ellsbury, whom they owe $21 million for the 2020 season and a $5 million buyout on a $21 million option for 2021.

By 8 p.m., the Yankees had to set their 40-man roster to make room for prospects they wanted to protect from being taken in next month’s Rule 5 draft held at the winter meetings in San Diego.

With their roster at 36 and not counting Domingo German, who is likely to be suspended for the start of the 2020 season, the Yankees added seven minor league players, released Ellsbury and designated first baseman Greg Bird and lefty Nestor Cortes Jr. for assignment.

Releasing the 36-year-old Ellsbury, who hasn’t played since the 2017 ALCS due to a buffet of injuries that included hip surgery late in the 2018 season, puts an end to the seven-year, $153 million contract the Yankees handed the left-handed-hitting center fielder before the 2014 season.

The Post learned that Ellsbury’s final season at $21 million wasn’t insured. Even released, Ellsbury and his annual average value of nearly $22 million would count toward the Yankees’ 2020 luxury-tax figure.

The Yankees added outfielder Estevan Florial and right-handed pitchers Deivi Garcia, Luis Gil, Brooks Kriske, Luis Medina, Nick Nelson and Miguel Yajure to the 40-man roster.

The move comes at a time when the Yankees could use outfield help because Aaron Hicks will likely miss the first two months of the season due to Tommy John surgery on his right (throwing) elbow.

In a late-October press conference, GM Brian Cashman didn’t sound like outfield help would come from Ellsbury.

“It’s hard to say based on how things have played out,” Cashman said. “Right now he’s not someone in a position health-wise where I can answer anything in the affirmative.”

The Yankees and free agent Brett Gardner are likely to extend a long relationship after Gardner started 94 games in center field when Hicks started the season on the injured list with a lower-back problem and later was shelved with an injury to his right flexor tendon. Mike Tauchman proved this past season to be a valuable piece, but he is best suited being available to play all three outfield spots.

In the four seasons with the Yankees in which he actually played, Ellsbury batted .264 with a .330 on-base percentage and posted a .716 OPS. The previous seven seasons with the Red Sox, Ellsbury batted .297 with a .350 on-base percentage with a .789 OPS.

Ellsbury’s last appearance in a Yankees uniform was as a pinch runner for Chase Headley in Game 4 of the 2017 ALCS against the Astros. In nine postseason at-bats in pinstripes, Ellsbury didn’t get a hit.

— Ken Davidoff in Arlington, Texas, and George A. King III in New York