President Trump and James B. Comey at the White House days after the inauguration.

WASHINGTON — Donald J. Trump asked Director James B. Comey of the F.B.I. to investigate and knock down a lurid but unverified report that placed Mr. Trump years earlier in a Moscow hotel suite with prostitutes, explaining to Mr. Comey that the fantastic story was untrue and was painful and distressing to his wife, Melania Trump.

Mr. Comey describes two January 2017 conversations between himself and Mr. Trump in “A Higher Loyalty: Truth, Lies and Leadership,” Mr. Comey’s new memoir, which is set to be released Tuesday. The New York Times acquired a copy of the book before its release, and accounts of the exchange appeared in reports by several other news organizations on Thursday evening.

By Mr. Comey’s accounts, Mr. Trump, then the president-elect, disputed the so-called Steele dossier, a document compiled by a former British intelligence officer that detailed an allegation in which Mr. Trump watched prostitutes urinate on each other. Mr. Comey writes that Mr. Trump insisted that “there’s no way I would let people pee on each other around me” in part because he is a self-professed germophobe. “No way.”

Four months later, Mr. Trump abruptly fired Mr. Comey, setting in motion a cascade of political and legal consequences that led directly to the appointment of Robert S. Mueller III as special counsel overseeing the federal investigation into Russian interference in the 2016 election. Mr. Comey and Mr. Trump have been engaged in a verbal war with each other, often on Twitter, since then.

The 304-page memoir by Mr. Comey is the only firsthand, insider account to emerge so far by a former Trump official describing what it was like to work in the chaotic early days of the administration. In it, Mr. Comey, a veteran law enforcement agent, writes unsparingly about Mr. Trump, calling him a tempestuous president whose connection to honesty was tenuous at best.

“This president is unethical, and untethered to truth and institutional values,” Mr. Comey writes in the book, saying his service to Mr. Trump recalled for him the days when he investigated the mob in New York. “The silent circle of assent. The boss in complete control. The loyalty oaths. The us-versus-them worldview. The lying about all things, large and small, in service to some code of loyalty that put the organization above morality and above the truth.”

With the book’s release set for next week, Mr. Comey is planning a media blitz, beginning with an intensely hyped interview with ABC News that is set to air Sunday night. Republican allies of Mr. Trump’s have already set in motion a counteroffensive, creating a “Lyin’ Comey” website aimed at discrediting the former F.B.I. chief.

Mr. Comey’s book does not include dramatic new revelations about the Russia investigation itself, which is continuing. But Mr. Comey does not pull punches as he provides rigorous detail — pulled from his contemporaneous notes — about his charged interactions with Mr. Trump during the transition and in the White House.

Laced with excruciating detail, Mr. Comey — who is 6 feet 8 inches tall — describes meeting Mr. Trump…