Jeff Hornacek has agreed in principle to be the Knicks’ new coach, a league source confirmed.

The Knicks are expected to announce the deal and hold a news conference by the end of the week to introduce Hornacek, according to the source. Yahoo’s The Vertical reported that Hornacek will sign a three-year deal to coach the Knicks.

Hornacek, 53, became the Knicks’ choice two weeks ago. The former Suns coach had two rounds of interviews with team president Phil Jackson and general manager Steve Mills, including a dinner in Manhattan on May 18.

The next day, the Knicks offered Hornacek the coaching job and he toured the team’s facility. Negotiations began on a contract that weekend and finally have reached a conclusion, although another source said the pact has not been signed as of yet.

Jackson also interviewed former Cavaliers coach David Blatt and former Pacers coach Frank Vogel, who was recently hired to coach the Magic. Jackson also spoke to Warriors assistant Luke Walton, who will be the Lakers’ new coach when Golden State’s playoff run ends.

Interim coach Kurt Rambis was considered a leading candidate because of his relationship with Jackson and his knowledge and affinity for the triangle offense, which is Jackson’s preferred offense.

Rambis was an assistant under Jackson with the Lakers and initially brought to the Knicks to be the associate head coach to Derek Fisher. Jackson appointed Rambis the interim coach after Fisher was fired, and he guided the Knicks to a 9-19 mark to end the season.

It remains possible that Rambis could stay on with the Knicks in some capacity, either in the front office working with Jackson or as an assistant to Hornacek, his former Suns teammate. Hornacek didn’t run the triangle offense in Phoenix.

Hornacek was 101-112 in 2½ seasons with the Suns, and finished runner-up in Coach of the Year voting after the 2013-14 season. He guided Phoenix to a 48-34 mark that season. Poor personnel decisions and injuries hampered Hornacek and the Suns after that. The Suns went 39-43 two seasons ago and Hornacek was fired in February with Phoenix 14-35.

He will take over a team that hasn’t reached the playoffs for three straight seasons. But the Knicks have a proven All-Star in Carmelo Anthony and talented 20-year-old phenom Kristaps Porzingis.

The Knicks don’t have a pick in this month’s draft, but they could try to acquire one. They also don’t have the quick, playmaking guards Hornacek had with the Suns that enabled him to often play small and fast. They also could look to trade for the kind of players that fit what Hornacek wants to run.

As a player, Hornacek was a sharpshooting, heady guard who spent 14 seasons in the NBA. A one-time All-Star, Hornacek averaged 14.5 points for the Suns, 76ers and Jazz, playing in 140 playoff games. He helped the Jazz reach back-to-back NBA Finals in 1997 and 1998, but Utah lost both times to Jackson’s Bulls.