After a heated auction that drew bids from about half a dozen publishers, James B. Comey, the former F.B.I. director, sold his book about ethics, leadership and his experience in government to Flatiron Books.

The book, which will be edited by Flatiron’s editorial director, Colin Dickerman, is scheduled to be published next spring, which is remarkably fast. The terms of the deal, which was reported on Wednesday by The Associated Press, were not disclosed. Mr. Comey, who began meeting with publishers last month, is represented by Matt Latimer and Keith Urbahn, partners at the literary agency Javelin.

“He’s hard at work on it right now,” Mr. Latimer said. “He wants to tell his story.”

In the book, Mr. Comey will look back on his two decades in government and recount his involvement in high-stakes cases against the Mafia and Martha Stewart, the politically charged investigation into Hillary Clinton’s use of a private email server and, most recently, his clashes with President Trump over the investigation into whether there was collusion between the Russian government and the Trump campaign. Mr. Comey will draw on these episodes to make a case for more ethical leadership.

In a news release announcing the deal, Flatiron dropped tantalizing hints that Mr. Comey would reveal new details about his interactions with the Trump administration, saying he would “share yet-unheard anecdotes from his long and distinguished career.”