The Yankees may not be on the hook for all of the $26 million they owe Jacoby Ellsbury.

The Post has learned, according to several people with knowledge of the situation, the Yankees are attempting to recoup some of the money by filing a grievance because Ellsbury used an outside facility to rehab injuries that kept him off the field for the past two seasons.

Ellsbury, who hasn’t played since the 2017 season due to several physical issues that included hip surgery in August 2018, was released by the Yankees on Wednesday night to make room for prospects on the 40-man roster.

When Ellsbury clears waivers, he will be officially released and the final leg of a seven-year, $153 million deal he signed before the 2014 season will be terminated.

The 36-year-old Ellsbury, meanwhile, is preparing to do something he hasn’t done in more than two years: play in a big-league game.

Ellsbury’s contract for 2020 is $21 million and there is a $5 million buyout on a $21 million option in 2021, which means he will clear waivers and become a free agent.

Ellsbury hasn’t played in the majors since Game 4 of the 2017 ALCS against the Astros, when he was a pinch runner.

He missed all of the 2018 season, first with an oblique strain and, after being treated for a lower-back issue, underwent surgery to repair a torn labrum in his left hip on Aug. 6, 2018. That procedure kept Ellsbury out for the entire 2019 season.

Considering the long layoff and hip surgery on a player whose legs on the bases and in center field made him attractive to the Yankees before the 2014 season it’s very difficult to project what teams will be interested in the career .284 hitter.

It has been six years since Ellsbury hit .298, posted a .355 on-base percentage and led the AL with 52 steals for the 2013 Red Sox, who didn’t re-sign him. And it has been eight years since Ellsbury hit .321 with 32 homers, 105 RBIs, had a .376 on-base percentage, a .928 OPS, made the All Star team for the only time and finished second in the AL MVP voting.

Since it only takes one team to believe it can get something out of Ellsbury, he likely will go to spring training with a major league club, but possibly on a minor league deal. After being a starter for so long, could Ellsbury accept a bench role on a contender? Would a rebuilding team have interest in a player who missed the past two seasons?

Obviously, the Yankees didn’t believe Ellsbury was going to be of any use to them. Cutting him while owing him $26 million was proof of that in a time when the Yankees could use help in the outfield. Switch-hitting center fielder Aaron Hicks isn’t expected back from Tommy John surgery on his right (throwing) elbow until at least June and left fielder Giancarlo Stanton has to rebound from a lost 2019 season in which he played in 18 games due to multiple injuries.

Brett Gardner and the Yankees are expected to extend a long relationship, but don’t forget injuries have limited Aaron Judge to a combined 214 games in the past two seasons.

Additional reporting by Ken Davidoff