He was once a rising star in the NYPD — and a finalist to be Mayor Bill de Blasio’s police commissioner.

But Chief of Department Philip Banks stunned city leaders when he resigned in late 2014, rather than take a promotion to the No. 2 spot in the department.

Now, The Post can reveal that Banks was the target of an ongoing federal corruption probe when he walked away from his job as one of the most powerful men on the force.

Investigators found “hundreds of thousands” of dollars in his bank accounts that raised red flags, sources said on Wednesday.

“He did bow out in kind of a strange manner,” said a source involved with the investigation.

The feds discovered the money while looking into his close relationship with two businessmen being probed for giving gifts to high-ranking NYPD members in exchange for favors.

“Banks had collected an inordinate amount of cash,” a source familiar with the case said. “Which begged the question, where is he getting this money? How is he getting it?”

“We were hearing about alleged gifts and all of these trips he was taking,” the source said.

When Banks stepped down in October 2014, he claimed that he was unhappy with his promotion to first deputy commissioner — a role that he felt was purely administrative.

“I felt that the position would take me away from where I could make the greatest contribution: the police work and operations that I love so much,” he said that month, after Police Commissioner Bill Bratton urged him not to quit.

Sources said Banks wasn’t officially informed of the investigation, but likely learned of it through his extensive law enforcement network.

“You know, he was the chief of the department, and he had a lot of hooks in the police department,” the source said.

Sources said the feds and the Internal Affairs Bureau were also tipped off that Banks had several rental properties in the names of relatives, and may have had a side business selling liquor.

As chief of department, Banks, whose wife is a nurse, had a salary of $201,096 in 2013 and 2014, records show.

The investigation into Banks and his businessman pals began with an IAB probe into an unnamed Bronx cop, sources said.

The NYPD called in the feds on that case, which eventually led to Jona Rechnitz and Jeremy Reichberg — who are suspected of giving gifts to high-ranking cops as part of an illegal quid pro quo, according to sources.

Banks and correction officers union chief Norman Seabrook took trips with Rechnitz, an Upper West Side real estate investor, and Reichberg, a leader in Borough Park, Brooklyn, sources said.

At least part of their bills were paid for by Rechnitz, sources said.

Banks also received two golf trips to the Dominican Republic, according to a government source, and got a free hotel stay in Israel, where he visited the Western Wall in Jerusalem with Rechnitz and Reichberg in October 2014.

A source close to Banks said he only became aware of the investigation after he stepped down as chief of department — and that’s when he hired celebrity lawyer Ben Brafman to represent him.

Brafman said Tuesday: “It does not appear that Mr. Banks, either while employed by the New York City Police Department or after he retired, was involved in any intentional criminal conduct.”

Additional reporting by Danika Fears