Masai Ujiri is expected to be the Knicks’ top target to replace Phil Jackson, sources told The Post. And after getting fleeced not once but twice by Ujiri, the Knicks hope to get the Raptors president to take one of the world’s most dysfunctional jobs — cleaning up Jim Dolan’s mess in the Garden.

Ujiri has spent most of his career in Denver and Toronto, where he took over as general manager in 2013 and built the Raptors into an Eastern Conference contender. On Wednesday, the Raptors announced they were promoting Bobby Webster to general manager and Ujiri would “continue to oversee basketball operations as president of the club.”

“If it’s true New York is looking at Masai … I understand why I’d do it. He put together two top seeds in Denver and Toronto — places [that] hadn’t done it,’’ David Thorpe, Ujiri’s first boss and mentor in the business, told The Post.

“His best strength is building the right culture, where people get along. … He builds an open, transparent culture. There’s a real conformity. The Spurs have been a better culture than everybody else, and Toronto is close.”

Ujiri, born and raised in Nigeria, was NBA Executive of the Year in 2013, when Denver won a club-record 57 games, and he got the best of the Knicks in the Carmelo Anthony deal. He took over as Toronto GM that offseason and immediately foisted Andrea Bargnani off on Knicks GM Glen Grunwald in exchange for Marcus Camby, Steve Novak, Quentin Richardson, two second-round picks and a lottery pick in 2016.

Bargnani became another Knicks bust, while the Raptors have gone 204-124 since.

“He’s done an excellent job in Toronto being a leader. Of course people have interest in him and want him. In our league, it’s something to be wanted. It’s something he earned,” Raptors coach Dwane Casey said Wednesday on SiriusXM Radio, before beginning to try to convince Ujiri to stay. “The team is ready to take the next step. We’re in a good situation. That’s my recruiting pitch to Masai.’’

What would the Knicks be getting if Ujiri, 46, instead bites on Dolan’s pitch?

“They’re going to get somebody who’s going to want results, and he’s been able to get jobs done quicker than expected,” Ujiri’s coach at Bismarck State, Buster Gilliss, told The Post. “He’s not one that’s going to sit around. He’s going to jump in, roll up his sleeves and get it done as quick and efficiently as he can. He’s one of those driven guys. He’s going to get there.”

He’s come far.

Ujiri got used to traveling, with a doctor for a mother and a father who was the head of nursing education in Nigeria. A toddler in England, he moved back to Nigeria at the age of 2, and by 13 had fallen in love with basketball. He’d read Basketball Digest or Sports Illustrated, watch VHS tapes, even watch movies such as “Come Fly With Me” or “The Fish That Saved Pittsburgh.”

Ujiri went to prep school in Seattle, and played at Bismarck State College and Montana State-Billings before a European pro career that included stops in Finland, Belgium, Greece and Germany.

“He was very driven, always real competitive. … I’m not surprised where he’s at. He always performed in outstanding fashion reaching goals,’’ Gilliss told The Post. “To get where he’s at, it’s a dream situation.”

While working as a youth coach in Nigeria, a chance meeting with Thorpe at summer league in 1999 gave him the chance he needed.

Thorpe — the executive director of the Pro Training Center in Clearwater, Fla. — invited him to the 2000 Final Four and introduced him around. Within days, Ujiri was fielding return calls from the likes of Geno Auriemma.

Ujiri started helping Thorpe train players, and when one had a workout scheduled with the Magic, Ujiri drove him there. After an hour with Orlando GM John Gabriel and coach Doc Rivers, he’d talked his way into a gig as a scout. Unpaid. He even paid for trips out of his own pocket, and roomed with players and other scouts.

But Ujiri was betting on himself, and it paid off, when Nuggets GM Kiki Vandeweghe hired him as an international scout. He left after four years to join the Raptors, and quickly went from the assistant GM to Denver’s executive vice president of basketball operations then back to Toronto’s president.

Will Knicks president be next?