In this salary-cap squeeze, Kevin Shattenkirk was the casualty.

The Rangers plan to buy out the remaining two years of the 30-year-old’s contract at $6.65 million per season, The Post has learned. In what was a confusing couple days when the time for the exact buyout window wasn’t clear to most around the league, the Blueshirts decided getting rid of Shattenkirk was the way they were going to free up space.

This will now leave the club with four years of dead cap space, but will give them quite a bit of relief this coming season. Having been into the summer allowance over the $81.5 million salary-cap ceiling, the Rangers will now carry a hit for Shattenkirk of $1.483 million this season, making them compliant for the time being. It will be followed by the big hit of $6.083 million in 2020-21 and then the next two seasons he would count for $1.433 million, all according to CapFriendly.com.

The window was made available because the Rangers’ second restricted free agent who had filed for arbitration, Pavel Buchnevich, signed a new contract Friday. Buchnevich’s deal wasn’t registered with the league until Saturday and this transaction was predicated on business days. So a three-day period that preceded the 48-hour buyout window didn’t start until Monday.

No matter how they got there, this is the end of Shattenkirk’s ill-lived tenure on Broadway. The New Rochelle product came home and struggled to deliver as well as he would have liked while dealing with an assortment of injuries right at the start of the first training camp in 2017. He finished his two seasons and 119 games by tallying seven goals and 44 points for the team he grew up rooting for.

Because of his no-move clause, Shattenkirk did not need to clear waivers. He will now be an unrestricted free agent — getting his money from the Rangers and free to sign a new deal with any team he chooses. Rest assured, this decision will be a motivating factor for a proud player who eschewed longer and more lucrative deals as a free agent in the summer of 2017 to come to New York. He was also always professionally candid about the disappointment in his performance while playing for the Rangers.

General manager Jeff Gorton had a couple of buyout options available, including fellow defensemen Brendan Smith and Marc Staal — both lefty-shots. But when the team added two righty-shot blueliners in Jacob Trouba and Adam Fox, it seemed Shattenkirk’s role on the roster had been drastically diminished. Both Trouba and Fox were likely going to slot in front of Shattenkirk on the power play. Defending was never Shattenkirk’s strength. He made his name as an offensive defenseman during seven solid years with the Blues.

But this summer, with the Rangers under the stewardship of new president John Davidson, they took a big leap forward in their rebuild. They traded for the 25-year-old Trouba and then signed him to a seven-year deal worth $8 million per . They also got the cream of the free-agent market in Russian winger Artemi Panarin, who inked a blockbuster seven-year deal worth a little more than $11.6 million per.

Despite all of the promising youth on the roster, that put the club in a rather tight financial bind. When Buchnevich signed his two-year deal worth $3.25 million per, it put the Rangers over the cap — and they still have yet to sign restricted free agents Tony DeAngelo and Brendan Lemieux to their respective one-year, $874,125 qualifying offers.

Gorton was able to bide some time with buying out Shattenkirk, while there are still some trade possibilities on the table. Those start with their most attractive piece, Chris Kreider, entering the final year of his deal with a $4.625 million cap hit. Extending Kreider would probably cost a seven-year deal around $7 million per to reach market value. There could be smaller salary-shedding deals done in moving two other players entering their walk years in Vladislav Namestnikov ($4 million) and Ryan Strome ($3.1 million).

But first came the unceremonious buying out of Shattenkirk, a noble but failed attempt at a marriage from both sides.