Minnesota Timberwolves center Karl-Anthony Towns follows through on his foul...

Minnesota Timberwolves center Karl-Anthony Towns follows through on his foul shot with one minute left in the fourth quarter against the Nets in an NBA game at Barclays Center on April 4. Credit: Kathleen Malone-Van Dyke

Just days ago, Julius Randle sat next to Tom Thibodeau on a stage in the Bronx. The two spoke glowingly about the Knicks and Thibodeau expressed praise for Randle’s attachment to the team and city.

But on Friday night, three days before the beginning of training camp, a league source confirmed that the Knicks had sent Randle, Donte DiVincenzo and a protected first-round pick (via Detroit) to the Minnesota Timberwolves for Karl-Anthony Towns — a massive shakeup of two championship-contending franchises.

The deal brings the Knicks a player who can take over at center — a gaping hole in the roster with Mitchell Robinson sidelined at least through December/January and Isaiah Hartenstein lost in free agency during the summer.

The Knicks will be able to slot the 7-foot Towns at center with Jalen Brunson, Mikal Bridges, OG Anunoby and likely Josh Hart. With the return of Anunoby and Randle from injury and the addition of Bridges, the crowded roster seemed bound to send DiVincenzo and Hart to the second unit, but the deal alleviates the crowd and fills the hole at center.

A league source pointed to the ability to create a key core of talent all under 30 years old and under contract long term, providing an opportunity for sustained success. The Knicks added the complementary talents of Towns — a dangerous three-point shooter and reliable offensive talent — around Brunson, Bridges and Anunoby. Towns, a four-time All-Star, shot 42% from three-point range last season.

According to an ESPN report, the Knicks were signing and trading Daquan Jeffries and draft compensation to the Charlotte Hornets to make the math work on the deal. Both teams are over the first apron and the Knicks were $7.6 million below the second apron. Minnesota was unable to take back more money than they were sending out and the Knicks needed to make up nearly $9 million to equal Towns’ salary.

While Randle was entering the last year of his contract, set to make approximately $29 million this season with a player option the following year, DiVincenzo is due $11.5 million this season, the second year of a four-year deal he signed with the Knicks last summer. Towns is due to make $49 million this season, the first year of a four-year, $220 million extension.

Towns, a New Jersey native and a former client of Knicks president Leon Rose during Rose’s tenure as an agent, spent all nine seasons of his career with the Timberwolves after arriving as the No. 1 overall pick out of Kentucky.

Randle was a three-time All-Star and two-time All-NBA member, all of it coming in his five seasons with the Knicks after he arrived as the first piece in the rebuild of a struggling franchise. But he was sidelined with a dislocated right shoulder in late January and missed the remainder of the season and the playoffs.

Randle, speaking with Newsday and the New York Post in May, said, “I’ve always said from the very beginning I would love to be here in New York and I would love to continue to add on to what the guys did in the playoffs. I feel like that was my personal — biggest personal goal or I’d say team goal in a sense, was when I got here is to be able to build and compete and to be at the point where we’re at now, where it’s an actual possibility. So really, that’s what my focus is, doing whatever I can to make sure I get healthy and get back and make sure I’m ready whenever we start playing again, contribute to winning.”

DiVincenzo was a key to the Knicks’ success last season, his first in New York, as he took over a starting job and clicked alongside Villanova teammates Brunson and Hart.

Towns became an All-Star for the first time in his third season, his second after Thibodeau took over as Timberwolves coach and team president, but tension within the organization led to Thibodeau’s departure. Towns has long been a player mentioned as a target of the Knicks’ front office.