The free agent contract was for $15.5 million over four years. By the time it expires, the Stars will wind up paying Sean Avery nearly $8 million (while being charged the same amount of salary-cap space) so he could play the grand total of 23 games for the team early in the 2008-09 season before drumming him out of Texas and back to New York, with one detour for anger management and another to Hartford, don’t forget.

It is a deal that almost makes Carl Pavano’s signing by the Yankees look popular by comparison.

When the Rangers meet the Stars on Friday night, Avery will skate in Dallas for the first time since Nov. 30, 2008, when he scored a goal in a 4-3 victory over the Oilers. That was two days before he uttered those two famous bad words — “sloppy seconds” — at the morning skate in Calgary that represented a cry for help and the first step toward his return to Fashion Avenue.

Avery was escorted out of town by a posse led by Marshall Tom Hicks that wanted to hang him high. He left Dallas a scorned man and left behind a wreckage of a relationship between himself and the franchise, between himself and the community. He returns a Ranger.

He returns contrite.

“I have to take the major portion of the responsibility for what happened in Dallas,” Avery told The Post on Wednesday. “They gave me a contract to come there and help the team win and when I got there, I didn’t adjust.

“I didn’t adjust to the conditions. I didn’t adjust to Texas as a whole, I didn’t adjust to the team, and when I say the team, I don’t mean the organization, I mean some of the guys in the room.

“I’m responsible 100 percent for that; 100 percent.”

It was a marriage that went bad pretty much on the wedding night. There never was a honeymoon. Brett Hull, the Dallas co-GM who had played with and befriended Avery in Detroit, was the one who set up the parties. It became the ultimate story of a blind date gone bad and it came with a cost.

For when Avery was banned by the NHL then all but fired with pay by then Dallas owner Hicks after comments aimed at Flames defenseman Dion Phaneuf, that marked the end of Hull’s job in the Stars’ hockey department and the end of Hull’s friendship with Avery.

“I apologize to Brett Hull,” Avery told The Post. “Brett Hull is the guy who saw that I could help his team, and I didn’t do that, and I hurt him.

“Obviously it hurt our relationship. That’s my No. 1 regret about the whole situation.”

Avery wants to make it clear, though, that he feels he had at least a reasonable relationship with most of his Dallas teammates — with two exceptions.

He won’t say their names, but it’s clear he is referring to Mike Modano and Marty Turco, longtime Stars who departed Dallas with a push out of the door as free agents over the summer, Modano to Detroit and Turco to Chicago.

“I was hung out to dry a lot by a couple of guys on that team,” Avery said. “They are two individuals who aren’t playing there anymore.

“I think people should be able to put the pieces of the puzzle together fairly easily.”

Avery has nothing but praise for Dallas captain Brenden Morrow.

“I’ve never had any kind of problem with Brenden Morrow,” Avery said. “I think he’s a great player and a great captain.

“That doesn’t mean I wouldn’t fight him if I have to, but he’s a good guy.”

The pieces never fit in Dallas for Avery from the moment he left the Rangers after 17 often tumultuous months on Broadway during which time he was among the Blueshirts’ best players in their only playoff round victories since 1997 — the 2007 first-round victory over Atlanta and the 2008 first-round victory over the Devils — to sign in Dallas. He was bringing his talents to the wrong place.

“Really, it seems like as soon as I got there, it didn’t fit right from the get-go,” said Avery, who finished with 10 points (3-7) with the Stars. “Once I felt that and had that feeling of almost isolation, I subconsciously started acting in a way that would push people away and that made the situation worse.

“It was kind of a defensive tactic more than anything. Anytime you’re feeling a little uncertain, like your back is to the wall, you react in a defensive way. That’s how I coped.”

When Avery plays against Dallas tomorrow night, the Stars will be paying half his paycheck, as they have since he went back to the Rangers on re-entry waivers on March 3, 2009. He most certainly expects to wear a target on his back.

“I can’t imagine why anyone would want to give me a warm reception there after what happened,” Avery said. “I signed with good intentions, I wanted to help the Stars win for all the money they were giving me.

“I look back, and it’s almost hard to believe all the stuff that happened there in such a short amount of time. Then there was the suspension and the rehab that got me back to New York. It just seems like they were all steps I had to go through.

“Thinking about it, the whole situation, and with some of the personalities involved, I don’t think anything would have made it work. It was the wrong place for me to go.

“It was doomed from the start.”