It was Christmas in July for Derek Stepan but a lump of coal in Jeff Gorton’s stocking, this gift of Buffalo’s seven-year, $52 million ($7.5 million per) extension to Ryan O’Reilly that kicks in next season and will keep on giving headaches to the Rangers and their newly installed general manager.

In a flash, Friday’s agreement between the needy Sabres and the 24-year-old center they obtained from Colorado last weekend blows to smithereens any hope the Blueshirts had of signing the 25-year-old Group II free agent center Stepan to a long-term deal in the range of $6.2 million to $6.5 million per.

It likely means Stepan, whose numbers are superior to O’Reilly’s in every meaningful category other than faceoff efficiency, not only will file for salary arbitration by Sunday’s 5 p.m. deadline, but could be in line for a two-year award taking him to unrestricted free agency worth well over $7 million per.

A quick review: Stepan: 89 goals and 163 assists equals 252 points in 362 games played, .70 points per game, plus-85, 50.7 Corsi rating, 18:18 minutes per game, 15 goals and 26 assists equals 41 points in 80 playoff games for a team having won eight series; O’Reilly: 90-156=246 in 427 GP, .58 PPG, minus-13, 49.8 Corsi, 18:26 per, 3-4=7 in 13 playoff games for a team that did not win a playoff series.

There will be other comparables presented at any arbitration hearing, but O’Reilly is going to hit close to home for sure. Keep this in mind: Of players 24 or younger as of Feb. 1, Stepan ranked seventh in the NHL in career points. Plus this: The fact O’Reilly was granted his contract by a team with a harbor full of cap space won’t be inadmissible in a hearing.

A number than starts with a “7” for Stepan is all but untenable for the Rangers as they are constructed. An award that’s closer to starting with an “8” than a “7” would place the ’15-16 Blueshirts’ roster in a cap vise. Beyond that, an arbitration award almost certainly starts the clock ticking on Stepan’s Broadway expiration date two years hence.

There is negotiating to be done here, negotiating between Gorton and Stepan’s representative, Matt Oates and, concurrently, negotiating between Gorton and league GMs regarding potential trades. Those not only would pertain to Stepan, but to either Rick Nash or Keith Yandle, with Yandle the most likely candidate to go, if the mandate is to clear space for No. 21.

If the Rangers believe Kevin Hayes is ready to become the team’s second-line center, then the Rangers could look for a package in return for Stepan that would include a legitimate, physical checking center that would change the look of the team.

The Blues might confront their own cap issues concerning their Group II winger, Vladimir Tarasenko, but a swap featuring David Backes — one year to go at $4.5 million — would have to be intriguing for the Blueshirts, as one example.

Nash would be on this list only because of his $7.8 million cap hit. He is the Rangers’ best player other than Henrik Lundqvist. A Nash trade would mark a dramatic reset. There is zero evidence the Rangers are considering going that route. Fact is, there hasn’t been a peep around the league about No. 61’s potential availability.

It’s a different dynamic with Yandle, whose $2.625 million cap hit (the other half absorbed by the Coyotes) is friendly enough, but who is a year away from unrestricted free agency with almost no chance of re-upping given the pricey long-term commitments already in place with lefties Marc Staal and Ryan McDonagh, behind whom Yandle sits on the depth chart.

Barring injury, Yandle is going to play on the third pair. No. 93 is great insurance but may not be affordable. Surely there is a pretty good market for such a reasonably priced defenseman.

(Yes, the Rangers could deal Kevin Klein and his $2.9 million per cap hit, but doing so weakens a vulnerable right side. Plus, Yandle likely is worth more on the market than Klein.)

Look, the Blueshirts traded Carl Hagelin in order to create space for Stepan. The objective always has been to keep the team’s top two-way center — who is coming off the best playoffs of his career — in New York, long term. Stepan is part of the nucleus, the club’s fourth senior player behind Lundqvist, Dan Girardi and Staal.

But Buffalo’s deal with O’Reilly complicates the mission. It has become much more difficult. Do the Blueshirts believe Stepan is worth the $7.5 million benchmark — or close to it — established by the Sabres and their titular first-line pivot? How much of a discount — if any — is reasonable to expect No. 21 to accept in order to accommodate the Blueshirts and become a Broadway lifer?

Christmas in July for Stepan. A coal in the stocking for Gorton and the Rangers.