Donald Trump engaged in a months-long effort to secure the loyalty of then-FBI Director James Comey in a series of meetings and phone calls that began in the presidential transition period -- behavior Comey likens to that of a mafia boss, Comey writes in a book set for release next week.

Those efforts included a now-famous, private White House dinner with Trump just a week after the president was inaugurated, in which Trump, Comey writes, told him: “I need loyalty. I expect loyalty.”

Comey writes that to him, “The demand was like Sammy the Bull’s Cosa Nostra induction ceremony,” referring to Salvatore “Sammy the Bull” Gravano, a former leader of the Gambino crime family, whose testimony ultimately helped convict mob boss John Gotti.

Comey responded with silence, he writes in the book, and Trump moved the conversation along. Later in the dinner, Trump returned to the subject: “I need loyalty.”

“You will always get honesty from me,” Comey writes that he responded.

“That’s what I want, honest loyalty,” Trump said.

“You will get that from me,” Comey responded.

The book, “A Higher Loyalty,” is Comey’s first extensive public accounting of his handling of investigations affecting Trump and Hillary Clinton – and the circumstances around his firing by Trump – since his congressional testimony last year.

In it, Comey paints Trump as someone who is “unethical, and untethered to truth and institutional values," and who is "ego driven and about personal loyalty.”

ABC News’ Chief Anchor George Stephanopoulos is conducting the first interview with Comey about the book, airing in a special edition of “20/20” on Sunday, April 15, at 10 p.m. ET.

A few weeks before his private dinner with the president, shortly before his inauguration, Comey had a similar feeling about mob loyalty pledges during his first meeting with Trump, he writes. Comey and other top intelligence officials were at Trump Tower to brief the president-elect, Vice President-elect Mike Pence, and a small circle of their top aides on Russian efforts to influence the election.

Rather than ask about how to meet the threat from Russia, Comey writes, Trump, Pence and incoming White House aides Reince Priebus and Sean Spicer quickly focused on “how they could spin what we’d just told them,” debating “how to position these findings for maximum political advantage.”

“I sat there thinking, Holy crap, they are trying to make each of us ‘amica nostra’ – friend of ours. To draw us in,” Comey writes. “As crazy as it sounds, I suddenly had the feeling that, in the blink of an eye, the president-elect was trying to make us all part of the same family and that Team Trump had made it a ‘thing of ours.’”

Weeks later, after the private dinner with Trump in which Comey says he agreed to give the president “honest loyalty,” Comey had another private Oval Office meeting with Trump. This time, he writes, Trump appeared to ask him to drop an FBI inquiry of fired National Security Adviser Michael Flynn.

“He is a good guy,” Trump told Comey, according to the book. “I hope you can let this go.”

“I did not interrupt the president to protest that what he was asking was inappropriate, as I probably should have,” Comey writes. “But if he didn’t know what he was doing was inappropriate, why had he just ejected everyone, including my boss [Attorney General Jeff Sessions] and the vice president, from the room so he could speak with me alone?”

The book also includes a detailed description of Comey’s handling of the investigation regarding Clinton’s use of a private email server during her time as secretary of state. That investigation led Comey to make a series of unusual and controversial public statements over the course of the summer and fall of 2016 – statements Clinton and others believe influenced the election.

Comey writes that he felt obligated to take more of a personal role as the public face of the investigation rather than deferring to then-Attorney General Loretta Lynch – in part because of something involving Lynch that he cryptically refers to as a “development still unknown to the American public to this day.”

In early 2016, the U.S. government became aware of information from a classified source, and “the source and content of that material remains classified as I write this,” according to the book.

“Had it become public, the unverified material would undoubtedly have been used by political opponents to cast serious doubt on the attorney general’s independence in connection with the Clinton investigation,” Comey writes, without further elaboration.

Comey asserts that he didn’t sense Lynch interfered with the investigation, even after the highly publicized Phoenix tarmac meeting between Lynch and former President Bill Clinton. That episode convinced Comey that he needed to step forward with his own public accounting of the email server investigation.

In an interview with NBC this week, in advance of the book’s publication, Lynch said she and Comey had a “full and open discussion” about the handling of the Clinton email case in the fall of 2015, and that “concerns were not raised.”

Comey maintains he handled the initial public statements around the Clinton investigation correctly, save for two small changes he would make in hindsight regarding how he described his decision not to pursue criminal charges in July 2016.

Comey writes that he should have said at the outset of his public statement that there would be no charges; his family, he writes, believed he was “Seacresting” – or building up a dramatic tease like television host Ryan Seacrest.

He also writes that he should not have used the term “extremely careless” to describe Clinton’s behavior, since it sounded roughly similar to “grossly negligent” – the legal standard for prosecution.

Comey reveals that he was first told in early October 2016 that a laptop belonging to former Rep. Anthony Weiner “might have some connection to the Clinton email case.” He said he believes Deputy FBI Director Andrew McCabe – who himself would be fired by Trump earlier this year – told him about it.

But Comey writes that he didn’t think much of it until Oct. 27, 2016, when McCabe said the Clinton email team needed to update him on what they were learning.

That led to a highly unusual series of public statements by Comey in the final two weeks before the election. He first announced the laptop might have relevant information and was being examined, and then said on the weekend before Election Day that nothing relevant was found in it.

“I have read she has felt anger toward me personally, and I’m sorry for that,” Comey writes, referring to Clinton. “I’m sorry that I couldn’t do a better job explaining to her and her supporters why I made the decisions I made.”

He adds that, shortly after the election, then-President Barack Obama personally offered his support for how he handled the job in an Oval Office meeting.

“I picked you to be FBI director because of your integrity and your ability,” Obama said, according to Comey. “I want you to know that nothing – nothing – has happened in the last year to change my view.”

Still, Comey writes that his public handling of the Clinton case – specifically, of providing more information to the public rather than less – may have been influenced by the widespread assumption that Trump would lose the election.

“Certainly not consciously, but I would be a fool to say it couldn’t have had an impact on me,” he writes.

“It is entirely possible,” he continues, that “my concern about making her an illegitimate president by concealing the restarted investigation bore greater weight than it would have if the election appeared closer or if Donald Trump were ahead in all polls. But I don’t know.”

The mindset that Clinton would win despite Russian involvement may have impacted Obama’s own handling of developments late in the campaign, according to Comey. When deliberating how to respond to Russian President Vladimir Putin’s apparent election meddling in September, Comey recalls Obama opting for fewer public warnings, and saying of Putin, “He backed the wrong horse.”

Comey surmises of Obama’s mindset: “And why give Donald Trump the excuse to blame Obama for frightening the American people? He was going to lose anyway.”

Comey, however, makes clear his affection for Obama – and his disdain for Trump and his leadership style. Though he did not vote in 2016, and secured his first high-profile government jobs under the Republican presidency of George W. Bush, he writes that his wife and daughters voted for Clinton and even participated in the Women’s March, held the day after the inauguration in Washington.

The book is peppered with unflattering personal observations about Trump. Comey, who is 6-foot-8, writes that Trump “appeared shorter than he seemed on a debate stage,” and says of the hand he offered for a handshake, “It was smaller than mine, but did not seem unusually so.”

Writing of their first meeting, in Trump Tower, Comey says the president-elect’s “face appeared slightly orange, with bright white half-moons under his eyes where I assumed he placed small tanning goggles, and impressively coiffed, bright blond hair, which upon close inspection looked to be all his. I remember wondering how long it must take him in the morning to get that done.”

Weeks later, as he recounts Trump’s apparent effort to pull him in for a hug while cameras rolled at a White House reception for law enforcement, Comey writes, “He was not going to get a hug without being a whole lot stronger than he looked. He wasn’t.”

At one point, Comey describes Trump’s manner of speaking as “an oral jigsaw puzzle contest, with a shot clock.”

Comey’s firing shook Washington. He recounts receiving an “emotional call” from John Kelly, then Trump’s secretary of Homeland Security and his current chief of staff, in the chaotic hours after Comey learned – first via TV news reports – that he had been fired.

In Comey’s telling, Kelly told him that he “intended to quit in protest” because “he didn’t want to work for dishonorable people who would treat someone like me in such a manner,” in an account that confirms reporting that first emerged last summer.

“I urged Kelly not to do that, arguing that the country needed principled people around this president. Especially this president,” Comey writes.

Comey concedes, as he did before Congress last year, that he sought to get information out to the public about his interactions with the president by asking a friend to describe memos he had dictated about his conversations with Trump. He writes that he did so only because Trump seemed to threaten him with a tweet suggesting there might be “tapes” of those conversations.

Comey writes that he revealed the February 2017 conversation during which he claims the president urged him drop an investigation of Flynn because “I didn’t trust the Department of Justice leadership under the current attorney general and deputy attorney general to do the right thing,” in pursuing possible tapes.

Comey’s claim that Trump urged him to “let it go” regarding the Flynn case “might force the Department of Justice to appoint a special prosecutor,” Comey writes.

That happened shortly thereafter, with Deputy Attorney General Rod Rosenstein’s appointment of special counsel Robert Mueller, whose investigation remains active. While Mueller intersects with Comey’s story throughout the book, especially during their years serving the Bush administration, Comey writes that he has no knowledge of what he’s pursuing. But he does have some theories.

“One of the pivotal questions I presume that Bob Mueller’s team is investigating is whether or not in urging me to back the FBI off our investigation of his national security adviser and in firing me, President Trump was attempting to obstruct justice, which is a federal crime,” Comey writes. “It’s certainly possible. There is at least circumstantial evidence in that regard, and there may be more that the Mueller team will assemble.”

Comey repeatedly expresses concern that the president is harming democratic institutions. In his epilogue, Comey refers to “the forest fire that is the Trump presidency.”