NEW YORK (AP) — Mike D’Antoni waited nearly four years before he could re-create the high-octane success he had in Phoenix, and for three exhilarating weeks in February, the New York Knicks were the NBA’s team to watch.

They played fast and fun, sharing the ball and sharing laughs, and their coach enjoyed the ride as much as anyone.

Just as quickly, it was gone again. And now, so too is D’Antoni, a casualty of the forces generated by a mercurial owner perpetually rebuilding the roster, the caprice of a star player and the heightened expectations of a fan base desperate for a winner.

He resigned Wednesday, a stunning finish for a coach who only a month earlier seemed rejuvenated by Jeremy Lin.

“Nobody saw it coming,” said Carmelo Anthony, the star who was sidelined when Lin emerged and seemed unlikely to ever mesh with him the way D’Antoni wanted after he returned.

That meant Linsanity couldn’t last, and D’Antoni may have realized it first.

Lin had come from the end of the bench to play so well that D’Antoni would compare him to Suns star Steve Nash, who ran his wide-open offense better than anyone. The undrafted Harvard point guard outplayed Kobe Bryant one night, toppled the champion Dallas Mavericks another, and D’Antoni had that feeling again that his team could outscore anyone.

“You know what, I think at that point in time we started to play well and he started to build on that offense,” forward Amare Stoudemire said.

The Knicks won seven straight, leading newscasts on a nightly basis for the first time in memory.

But D’Antoni also had the same fear as many fans. He knew Anthony would soon be back from injury, and his vision of beautiful basketball would stop.

And when that happened, followed by reports of the friction it created between the coach and star, D’Antoni decided it was time to walk away.

“He had a certain ideal of a system we were supposed to implement,” said Stoudemire, who also played for D’Antoni in Phoenix. “We all didn’t quite buy into it, and he got frustrated and I think that’s why he took his way out.”

His departure may have been hardest on Lin, who was barely hanging on to an NBA job before D’Antoni’s schemes catapulted him onto two straight Sports Illustrated covers and TV screens around the world.

“Obviously, I miss him a lot,” Lin said after the Knicks’ 121-79 victory over Portland under interim coach Mike Woodson. “What he did for me and my career, I’m not going to forget. I’m not going to forget what he did for me personally. Just very emotional and sad to see him go. I owe a lot to him.”

Minutes after he spoke, it was clear the same affection didn’t exist between D’Antoni and Anthony.

D’Antoni communicated with some players via phone or text message Wednesday afternoon, but Anthony said he hadn’t talked to him since a brief conversation when D’Antoni ran the Knicks’ morning workout. He acknowledged the sacrifice it took for him to play in D’Antoni’s system, where he didn’t get the ball as much as he wanted, but denied having any role in the coach’s resignation.

“I didn’t have anything to do with that. That was Coach’s decision,” Anthony said. “I really don’t know where his mindset was at, what he thought, what he was thinking as far as his decision to step down. So anything about me and Mike, you guys who probably know Mike personally, anything like that, he will tell you we never had any issues. Any disagreements that he had with us as a team, we talked it out and went from there.”

D’Antoni was a coaching star in Phoenix, averaging 58 wins in four full years. He got a big contract to come to the big city, but rarely much chance to compete. He sat through two years of rebuilding and too many trades that halted momentum while failing to deliver the type of roster he craved, and interim general manager Glen Grunwald admitted D’Antoni had a “rough go of it” in New York.

Still, the Knicks went 42-40 last season to make the playoffs with their first winning record in a decade, and they were a basketball story again after years of mostly being in the headlines for all the wrong reasons during Isiah Thomas’ tenure.

D’Antoni relished being relevant again, his easygoing personality and quick wit returning as the success of Lin and the team brought more media attention. He joked one day after meeting with the large Asian contingent that came to cover the NBA’s first American-born player of Chinese or Taiwanese descent that he felt like he was opening for the Beatles.

But with the Knicks mired in a six-game losing streak, his final days brought back the way it was before his arrival. Anthony wanted a trade and D’Antoni had lost the support of players, according to two of the stories based on anonymous sources that appeared Wednesday morning.

Perhaps that’s when D’Antoni made his decision. He wasn’t able to turn the Knicks into a regular winner again and seemed unlikely to return anyway, with his $24 million, four-year contract set to expire this summer.

“I think in life there are times where change could be for the better,” Anthony said. “This is an unfortunate situation for Coach Mike, but sometimes something will just spark off for guys to wake up and say, ‘OK, something is real right here and we got to change.’ Obviously, I’m not speaking for Coach, but that’s how he felt. He stepped down for the sake of the team. He felt like the team needed change and he did that. I wish it was under better circumstances, but at this point it is what it is.”