Scott Perry, the Sacramento Kings’ vice president of basketball operations, has agreed to become the Knicks general manager — the No. 2 job in the front office under acting president Steve Mills.

Perry agreed to a deal with the Knicks after meeting with Mills on Thursday, an NBA source confirmed.

As The Post has reported, the Knicks have their successor to ousted president Phil Jackson in Mills, who served as general manager during the three-year, three-month stint of the Zen Master. The Knicks have not made Mills’ promotion official, but proceeded with a GM search centering on assistant general-manager types.

Perry was hired by the Kings in April to be the right-hand man for Vlade Divac, who runs the Kings front office. The Kings gave the Knicks permission to talk to Perry but reportedly are asking for financial compensation.

During his short stint in Sacramento, Perry played a part in drafting former Kentucky point guard De’Aaron Fox with the fifth pick in last month’s NBA draft. The Kings also drafted North Carolina’s Justin Jackson and Duke’s Harry Giles in the first round. In free agency, the Kings signed veterans George Hill, Vince Carter and Zach Randolph.

“One of the top evaluators of talent in the NBA,” said one NBA executive who has worked with Perry. “The evidence is Sacramento’s free agency this year.”

However, Perry, a longtime member of the Pistons’ front office, joined the Kings after being part of the failed Orlando staff, getting fired in April. Perry was assistant GM to Rob Hennigan, who was also let go.

Two team executives, however, found it odd Sacramento would agree to let him leave so quickly.

“It’s a little strange, getting fired in Orlando, then going to Sacramento and they’re willing to let him go so soon after a few months,’’ an NBA executive said.

In Orlando, the Magic could never build anything close to a winner. Perry helped draft guard Victor Oladipo in 2013 and Aaron Gordon — two decent picks.

But Perry has so far missed on guard Elfrid Payton in 2014 with the 10th pick (they traded Dario Saric’s rights to get him). Worse, the Orlando staff missed on guard Mario Hezonja in 2015 with the fifth pick after losing out on Kristaps Porzingis by one slot.

Perry started out in a management role with the Pistons in 2000 under Joe Dumars, which included an NBA title in 2004.

Perry worked for the Pistons when they bypassed Carmelo Anthony for Darko Milicic in the 2003 draft. Now Perry will attempt to deal Anthony to the Rockets in a multi-team deal, a potential trade put in motion by Mills.

The Knicks have courted Perry for more than a week — with former Staples Center executive Tim Leiweke gathering a pool of candidates as head of the search.

Perry’s résumé is vast and fellow executives admire his bevy of contacts. He served as the assistant general manager for the Seattle Supersonics for one season (2007–08) on the staff that drafted Kevin Durant.

Perry then returned to the Pistons to become vice president of basketball operations from 2008-2012.

David Griffin, the former Cavaliers general manager, also interviewed for the Knicks front-office position, but pulled his name from consideration when he realized he would be No. 2 to Mills.

Mills was the Knicks’ president to start the 2013-14 season, a surprise replacement for Glen Grunwald, who built the previous season’s 54-28 club.

With Jim Dolan expecting a championship contender, the Knicks, rife with injuries, sputtered under Mills. Five months into the job, Mills was demoted to GM as Dolan hired Jackson — one of his most foolish missteps as owner.

Now it will be a Mills-Perry connection and perhaps Allan Houston promoted back to his assistant GM role. If the Knicks don’t have the most marquee front office, Dolan hopes they have stability and a friendlier relationship with the media.

It is unclear if Perry will bring in any of his own people — a sticking point with Griffin. One candidate could be George David, longtime former Pistons personnel man who worked with Perry for more than 10 years.