This should have been a marriage that lasted for years, maybe for more than a decade. The Knicks drafted Kristaps Porzingis in 2015, and it appeared as if the then 19-year-old 7-foot-3 phenom would become a franchise pillar.

Instead, the relationship began to fray until it stunningly fractured nine-plus months ago with his trade to Dallas.

Porzingis became upset at the Knicks’ unwillingness to hire his physiotherapist, grew alarmed with their treatment of former teammate (and Porzingis’ face-of-the-franchise predecessor) Carmelo Anthony and established little trust in Knicks president Steve Mills’ direction of the team.

The Knicks, meanwhile, believe Porzingis began exhibiting diva behavior (including blowing off his exit meeting with management following the 2016-17 season and cursing at his coach during practice), developed concerns about his brother/agent and felt Porzingis was becoming detached from the team. The relationship cratered in January, when Porzingis’ camp told the Knicks the All-Star big man would not commit to the team long-term and requested a trade.

Through multiple interviews with sources and people familiar with the relationship, here’s how the Knicks and Porzingis went from happily ever after to divorce court.

As a rookie, Porzingis behaved immaculately, played like a future superstar and earned the nickname Unicorn. He came back less of a fairy tale in his second season, according to multiple sources.

“He changed,’’ one NBA source said.

On occasion at the Tarrytown practice headquarters, Porzingis started parking his car haphazardly in front of the players’ entrance instead of in the assigned parking spot that each player receives.

The symbolism was clear. Porzingis was going to do things outside the lines.

During that second season, Porzingis came up with an excuse to miss the Knicks’ annual charity Bowl-athon — the biggest season-ticket holder event the franchise has.

And after then-coach Jeff Hornacek told him during a practice to show more toughness on defense, Porzingis blurted back, “F–k you.’’ Hornacek was shocked.

Before his rookie season, Porzingis was a happy guest of the U.S. Open, sitting in a President’s Box suite to cheer on Latvian players. The following September, the Porzingis camp asked for tickets again to watch his Latvian compadres. This time, an inordinate amount of free seats were requested. When the USTA couldn’t accommodate all of them, Porzingis cancelled.

By the end of his second season with the Knicks, the spit hit the fan.

Porzingis blew off his exit interview in April 2017. It was without warning, but had been plotted for weeks by Porzingis’ brother/agent Janis Porzingis.

Porzingis’ protest was to demonstrate disenchantment with the direction in which the franchise was headed under former president Phil Jackson and Mills, then the GM.

The ploy blindsided Jackson and Mills — stoking the beginning of the end for Porzingis in New York.

It wasn’t until last Jan. 30, his fourth in New York, that Porzingis’ Knicks career ended. It came less than an hour after a four-minute meeting attended by Porzingis, Janis, Mills and new GM Scott Perry.

Janis Porzingis called the meeting for a week before the trade deadline. He informed Mills that his brother wouldn’t commit to signing long-term on July 1. He asked for a trade, or said they would head back to Spain to rehab from Porzingis’ torn ACL.

For more on the Knicks, listen to the latest episode of the “Big Apple Buckets” podcast:

By then, Mills felt he had done all he could to convince Janis Porzingis that New York was the place for his brother. An hour after the meeting, Janis Porzingis called Mills with his four-team wish list, headed by the Clippers and Nets.

It was too late. Mills had already cut a deal with the Mavericks — a team not on the list. Talks with Dallas had escalated the night before, when the Mavericks were at the Garden. Mills knew the next day’s meeting was the make-or-break moment. And most likely it would be “break.”

Mills declined to comment for this story. The Knicks pointed to a statement Mills made to MSG Network after the trade.

“If we let this go beyond the [Feb.] 7th [trade deadline] the leverage would have shifted,’’ Mills said. “We would not have control over the situation. We weren’t sure what Kristaps was going to come in and tell us. We don’t know if he would have told us that he wanted to be traded or he may have wanted to sign a one-year contract with a player option, which would’ve made him untradeable, and have given him all the leverage. We needed to have some certainty by the 7th. They made it clear to us, in a meeting that they requested, that he didn’t want to play for the Knicks and he wasn’t going to re-sign with us as a free agent.’’

Porzingis never played a game for the Knicks under coach David Fizdale, whose club faces Porzingis’ Mavericks on Friday at American Airlines Center. It is a basketball tragedy from which the Knicks have yet to recover.

“Everyone’s going to hunt for happiness and comfort,’’ Fizdale said on the eve of the showdown. “That was a decision he had to make. So here we are today.”

Porzingis probably didn’t know it, but after his rookie season, Jackson sought trade offers for the No. 4-overall pick of 2015, according to a source. His rookie year was promising (14.3 points, 7.3 rebounds and 1.9 blocks per game) except for a few minor injuries. Jackson looked at the big picture, though. The Zen Master was afraid durability could be a long-term issue. He was uncertain Porzingis would become a viable No. 1 option — a franchise player to build a team around.

Jackson noticed players much shorter than Porzingis — but more muscular — had success defending him in post-ups. Porzingis’ balance on his shot also was a concern.

Jackson theorized he might be able to get back two All-Stars and another future piece for Porzingis because of the New York hype machine. But Jackson never pulled the trigger. But after Porzingis blew off his exit meeting, Jackson was at it again, soliciting offers before the 2017 draft.

The Celtics offered a trove of assets, including Jaylen Brown, in a scenario under which the Knicks could move up and select future Bulls forward Lauri Markkanen, but again Jackson held back. Some in the league believe Jackson didn’t make the trade on orders from owner James Dolan. Who would’ve thought then it would turn into one of Jackson’s and Dolan’s worst miscalculations?

“Phil didn’t like the brother,’’ said Charley Rosen, a Jackson confidant. “He thought he was too inexperienced.’’

Porzingis became Mills’ problem when Jackson was fired only days after that 2017 draft — partly due to the Porzingis rift. Mills was elevated to the presidency but ultimately never found a way to soften Janis Porzingis’ concerns about the direction of the franchise.

Mills could not shake being Jackson’s right-hand man who helped steer Anthony out of town. Porzingis looked up to Anthony. The Knicks believe Melo may have helped poison the waters with Porzingis.

“His brother and KP didn’t take it well when the Knicks were trying to run Carmelo out of town,’’ said Rosen, author of a new book, “Truth and Lies in Basketball.” “They felt management wasn’t showing proper respect for their best players. As a young player, he saw that as a management trend he didn’t want to be part of.”

Usually in a divorce, both parties make errors along the way and Mills’ decision not to pay a visit to Porzingis in Latvia that summer was one of them. Porzingis spent the entire offseason in Europe until two days before training camp.

Mills, too, presided over that summer’s firing of Josh Longstaff, Porzingis’ favorite assistant coach. However, Longstaff had alienated himself from the rest of Hornacek’s coaching staff.

“It had nothing to do with KP,’’ one source close to Hornacek said.

On his own dime, Porzingis brought over his Spanish League physiotherapist, Manolo Valdivieso, to New York for his third season. The Post reported Janis Porzingis had hoped the Knicks would put Valdivieso on the payroll and give him access to the facilities. Janis also campaigned for a job with the organization but got no traction.

Some in the organization believe that issue was as much a factor in Janis souring on the Knicks as his not trusting Mills to build a winner was.

After the trade, Mavericks owner Mark Cuban and coach Rick Carlisle gave shoutouts to Valdivieso and Janis at the introductory press conference. Valdivieso was hired for Dallas’ training staff, but works mostly with Porzingis and rides the team plane to all road games, according to an NBA source.

The Knicks’ rampant losing in 2017-18 didn’t help in Porzingis’ third season despite a blockbuster start and being voted an All-Star. But whatever joy was generated by that announcement had ended for good on Feb. 6, 2018, when Porzingis tore his ACL on a dunk attempt over Giannis Antetokounmpo.

The healing of the ACL should have coincided with the healing of harsh feelings amidst the two sides. But it never seemed quite right. While the Knicks were privately disappointed Porzingis chose to rehab over the summer in Spain at Real Madrid’s facilities, they supported the move. The Knicks sent medical personnel to Spain.

Still, the Knicks were surprised Janis Porzingis didn’t trust their medical director, Lisa Callahan, a former team doctor for Team USA. The Knicks also use one of the most famous facilities in the world for knee rehabs — the Hospital for Special Surgery.

When Porzingis returned from Europe before last season, still rehabbing, hope was rampant the bad blood was behind them as he entered his contract’s final year. Fizdale flew out to Latvia for four days in August with his wife, Natasha.

That October, a woman who said she was raped by Porzingis at their Manhattan apartment building in February 2018 reportedly contacted the Knicks to involve the team’s legal department in mediating the situation. According to a source, the complaint — which was brought to the NYPD this March — has not yet been closed. Porzingis has denied the allegation.

As the season progressed, Porzingis became more detached. According to a source, the team’s training staff met with Porzingis’ trainers and mapped out a plan in which he would come in early to the facility before the Knicks’ practices. That meant he would spend very little time around his teammates.

The Knicks were getting especially bad vibes in January and a stronger feeling Porzingis had no intention of playing in 2018-19. As Porzingis was ready to start on-court basketball drills with the assistant coaches, he stopped showing up. Mills and Perry had started talking to other teams after Christmas, fearing the worst.

The trade hasn’t worked out for the Knicks. The cap space they got in the deal didn’t net a free-agent star and Dennis Smith Jr. hasn’t panned out yet.

To his credit, Porzingis has not aimed darts at the Knicks since the trade. On Thursday, Porzingis said the ending was “a little bit ugly.’’ As with all divorces.