Fired Manhattan US Attorney Preet Bharara has gotten a million-dollar book deal, The Post has learned.

Alfred A. Knopf, a division of Penguin Random House, found Bharara’s proposal “long enough and strong enough” that they wanted to prevent him from shopping it around, said a person with knowledge of the deal.

Knopf on Thursday revealed that Bharara will write the book, to be published in January 2019, about “the search for justice — not just in criminal cases but in life and society in general.”

Bharara hinted that he plans to use the space to present himself as a man of upstanding character and to paint his seven-and-a-half year tenure as New York’s top federal law enforcement official in a glowing light.

“This is not a book just about the law. It is a book about integrity, leadership, decision making, and moral reasoning,” Bharara said in a statement.

“It addresses what it means to do the right thing, how to avoid doing the wrong thing, and the role of thoughtfulness in making the best choice,” he said.

What readers are really interested in, however, is his firing by President Trump and his high-profile battle with billionaire Steve Cohen, which inspired Showtime’s “Billions,” one editor said.

Bharara didn’t return a request for comment.

The book deal comes as the fired prosecutor attempts to position himself as a defender of the US justice system — and in contrast to President Trump.

Bharara has accused the president of inappropriate calls to his office in an effort to “cultivate some kind of relationship” leading up to his high-profile firing in March. ​​

The former prosecutor, who went on to become a “distinguished scholar in residence” at NYU School of Law, has also criticized Trump for his controversial firing of FBI director James Comey amid an probe into possible ties between the Trump campaign and Russia.

Earlier this month, he told ABC “This Week” that Comey’s account of the firing “felt a little bit like deja vu.”

To be sure, Bharara racked up some important victories during his time as NY’s top cop, starting with dozens of insider trading cases that took down hedge fund billionaire Raj Rajaratnam and former Goldman Sachs director Rajat Gupta.

He also led public corruption convictions into high-ranking New York officials, including former Speaker of the New York State Assembly, Sheldon Silver, and the Majority Leader of the State Senate, Dean Skelos.

His tenure was not without setbacks, however, including the reversal of his 2013 conviction of Gilberto Valle, the so-called “cannibal cop.” In an embarrassing reversal, the Manhattan federal judge who oversaw the trial determined that the feds failed to prove Valle did anything more than fanaticize about kidnapping and harming women, which is not a crime.

Despite the speeches and other efforts to boost his public profile, Bharara has repeatedly said he has no plans to run for office.