In a stunning development late Sunday night, the Los Angeles Lakers opted to sign former Knicks and Suns coach Mike D’Antoni to a four-year deal as their next coach, ending negotiations with 11-time NBA champion coach Phil Jackson. He was believed to be the prohibitive favorite to replaceMike Brown, who was fired last Friday.

D’Antoni and former Lakers, Blazers, Bucks and Clippers coach Mike Dunleavy interviewed with the Lakers over the weekend. But they were fallbacks, interviews done just in case the Lakers, somehow, could not reach a deal with the 67-year-old Jackson, who’d won five titles in Los Angeles during two stints as head coach.

But the Lakers could not reach agreement with Jackson, whose representatives had made it clear last summer that Jackson wanted a much bigger role in any organization that he joined, with hiring authority for coaches and other positions in the organization.

Negotiations with Jackson ended Sunday night, and the Lakers called D’Antoni’s agent, Warren LeGarie, as their home game against the Kings was ending. The two sides quickly worked out a contract somewhat along the lines of what Brown — another LeGarie client — received, though specific dollar amounts were not immediately available.

The Lakers never contacted other potential coaching candidates like former Blazers coach Nate McMillan, or former Jazz coach Jerry Sloan.

In the end, D’Antoni’s relationships both with Steve Nash, whom he helped get two MVPs in Phoenix, and with Kobe Bryant, who has known D’Antoni since he was finishing his playing career in Italy when a young Bryant lived there, made him the choice over Dunleavy.

D’Antoni’s Suns gave as good as they got with the Lakers in the playoffs, rallying from a 3-1 deficit to defeat L.A. in a 2006 first-round series. And his “Seven Seconds or Less” offensive system, which demanded pushing the ball up court — even after opponents scored — to get a good shot early in the shot clock, was much more in line with the old “Showtime” Lakers of Magic Johnson than the halfcourt-based Princeton offense that Brown tried to run.

The Lakers fired Brown Friday morning, despite executive vice president Jim Buss having given him a vote of confidence the day before. And despite everyone, including Bryant, stressing patience as the team dealt with injuries and the learning curve with the Princeton sets.

D’Antoni badly wanted the Lakers job, and an opportunity to again coach the now 38-year-old Nash. He was disturbed by how his stint in New York ended, without a playoff appearance, and with him resigning in March after Knicks management refused his entreaties to try and trade star forward Carmelo Anthony.

D’Antoni had knee replacement surgery about two weeks ago, and has to be cleared by his physician to be allowed to travel. He is already walking and his in-house therapist believes D’Antoni is about a week of rehab away from being able to handle coaching’s rigors. The current plan is for D’Antoni to be in Los Angeles by Wednesday or Thursday. The Lakers play the Spurs Tuesday night at Staples Center, but per LeGarie, D’Antoni will not be in attendance for that game. Bernie Bickerstaff, who has coached the Lakers to two wins on an interim basis, would probably coach that game, then.

LeGarie says that D’Antoni will not conduct any interviews before being introduced by the Lakers. D’Antoni will likely be put on an accelerated rehab program when he arrives in Los Angeles.

D’Antoni’s older brother, Dan, who has been with him on the bench in Phoenix and New York, will be joining Mike D’Antoni on the Lakers’ staff, according to a source. It is unknown if any of the Lakers’ current assistant coaches will be retained, though it is possible that Bickerstaff could be asked to stay.