John Dowd was convinced that President Donald Trump would commit perjury if he talked to special counsel Robert Mueller. So on Jan. 27 the president's then-personal attorney staged a practice session to make his point.

In the White House residence, Dowd peppered Trump with questions about the Russia investigation, provoking stumbles, contradictions and lies until the president eventually lost his cool.

"This thing's a goddamn hoax," Trump erupted at the start of a 30-minute rant that finished with him saying, "I don't really want to testify."

The dramatic and previously untold scene is recounted in "Fear," a forthcoming book by Bob Woodward that paints a harrowing portrait of the Trump presidency, based on in-depth interviews with administration officials and other principals.

Woodward writes that his book draws from hundreds of hours of interviews with firsthand participants and witnesses that were conducted on "deep background," meaning the information could be used but he would not reveal who provided it. His account is also based on meeting notes, personal diaries and government documents.

Woodward depicts Trump's anger and paranoia about the Russia inquiry as unrelenting, at times paralyzing the West Wing for days. Learning of the appointment of Mueller in May 2017, Trump groused, "Everybody's trying to get me" - part of a venting period that shellshocked aides compared to Richard Nixon's final days as president.

A copy of the 448-page book was obtained by The Washington Post. Woodward, an associate editor at The Post, sought an interview with Trump through several intermediaries to no avail. The president called Woodward in early August, after the manuscript had been completed, to say he wanted to participate. The president complained that it would be a "bad book," according to an audio recording of the conversation. Woodward replied that his work would be "tough," but factual and based on his reporting.

A central theme of the book is the stealthy machinations used by those in Trump's inner sanctum to try to control his impulses and prevent disasters, both for the president personally and for the nation he was elected to lead.

Woodward describes "an administrative coup d'etat" and a "nervous breakdown" of the executive branch, with senior aides conspiring to pluck official papers from the president's desk so he couldn't see or sign them.

Again and again, Woodward recounts at length how Trump's national security team was shaken by his lack of curiosity and knowledge about world affairs and his contempt for the mainstream perspectives of military and intelligence leaders.

At a National Security Council meeting on Jan. 19, Trump disregarded the significance of the massive U.S. military presence on the Korean Peninsula, including a special intelligence operation that allows the United States to detect a North Korean missile launch in seven seconds (versus 15 minutes from Alaska), according to Woodward. Trump questioned why the government was spending resources in the region at all.

"We're doing this in order to prevent World War III," Defense Secretary Jim Mattis told him.

After Trump left the meeting, Woodward recounts, "Mattis was particularly exasperated and alarmed, telling close associates that the president acted like - and had the understanding of - 'a fifth- or sixth-grader.'"

In Woodward's telling, many top advisers were repeatedly unnerved by Trump's actions and expressed dim views of him. "Secretaries of defense don't always get to choose the president they work for," Mattis told friends at one point, prompting laughter as he explained Trump's tendency to go off on tangents about subjects such as immigration and the news media.

Inside the White House, Woodward portrays an unsteady executive detached from the conventions of governing and prone to snapping at high-ranking staff members, whom he unsettled and belittled on a daily basis.

- - -

White House Chief of Staff John F. Kelly frequently lost his temper and told colleagues that he thought the president was "unhinged," Woodward writes. In one small group meeting, Kelly said of Trump: "He's an idiot. It's pointless to try to convince him of anything. He's gone off the rails. We're in Crazytown. I don't even know why any of us are here. This is the worst job I've ever had."

Reince Priebus, Kelly's predecessor, fretted that he could do little to constrain Trump from sparking chaos. Woodward writes that Priebus dubbed the presidential bedroom, where Trump obsessively watched cable news and tweeted, "the devil's workshop," and said early mornings and Sunday evenings, when the president often set off tweetstorms, were "the witching hour."

Trump apparently had little regard for Priebus. He once instructed then-staff secretary Rob Porter to ignore Priebus, even though Porter reported to the chief of staff, saying that Priebus was "'like a little rat. He just scurries around.'"

Few in Trump's orbit were protected from the president's insults. He often mocked former national security adviser H.R. McMaster behind his back, puffing up his chest and exaggerating his breathing as he impersonated the retired Army general, and once said McMaster dresses in cheap suits, "like a beer salesman."

Trump told Commerce Secretary Wilbur Ross, a wealthy investor eight years his senior: "I don't trust you. I don't want you doing any more negotiations. . . . You're past your prime."

- - -

A near-constant subject of withering presidential attacks was Attorney General Jeff Sessions. Trump told Porter that Sessions was a "traitor" for recusing himself from overseeing the Russia investigation, Woodward writes. Mocking Sessions' accent, Trump added, "This guy is mentally retarded. He's this dumb Southerner. . . . He couldn't even be a one-person country lawyer down in Alabama."

At a dinner with Mattis and Gen. Joseph F. Dunford Jr., the chairman of the Joint Chiefs of Staff, among others, Trump lashed out at a vocal critic, Sen. John McCain, R-Ariz. He falsely suggested that the former Navy pilot had been a coward for taking early release from a prisoner-of-war camp in Vietnam because of his father's military rank and leaving others behind.

Mattis swiftly corrected his boss: "No, Mr. President, I think you've got it reversed." The defense secretary explained that McCain, who died Aug. 25, had in fact turned down early release and was brutally tortured during his five years at the Hanoi Hilton.

"Oh, okay," Trump replied, according to Woodward's account.

With Trump's rage and defiance impossible to contain, Cabinet members and other senior officials learned to act discreetly. Woodward describes an alliance among Trump's traditionalists - including Mattis and Gary Cohn, the president's former top economic adviser - to stymie what they considered dangerous acts.

"It felt like we were walking along the edge of the cliff perpetually," Porter is quoted as saying. "Other times, we would fall over the edge, and an action would be taken."

After Syrian leader Bashar al-Assad launched a chemical attack on civilians in April 2017, Trump called Mattis and said he wanted to assassinate the dictator. "Let's fucking kill him! Let's go in. Let's kill the fucking lot of them," Trump said, according to Woodward.

Mattis told the president that he would get right on it. But after hanging up the phone, he told a senior aide: "We're not going to do any of that. We're going to be much more measured." The national security team developed options for the more conventional air strike that Trump ultimately ordered.

- - -

Cohn, a Wall Street veteran, tried to tamp down Trump's strident nationalism regarding trade. According to Woodward, Cohn "stole a letter off Trump's desk" that the president was intending to sign to formally withdraw the United States from a trade agreement with South Korea. Cohn later told an associate that he had removed the letter to protect national security and that Trump did not notice it was missing.

Cohn made a similar play to prevent Trump from pulling the United States out of the North American Free Trade Agreement, something the president has long threatened to do. In spring 2017, Trump was eager to withdraw from NAFTA and told Porter: "Why aren't we getting this done? Do your job. It's tap, tap, tap. You're just tapping me along. I want to do this."

Under orders from the president, Porter drafted a notification letter withdrawing from NAFTA. But he and other advisers worried that it could trigger an economic and foreign relations crisis. So Porter consulted Cohn, who told him, according to Woodward: "I can stop this. I'll just take the paper off his desk."

Despite repeated threats by Trump, the United States has remained in both pacts. The administration continues to negotiate new terms with South Korea as well as with its NAFTA partners, Canada and Mexico.

Cohn came to regard the president as "a professional liar" and threatened to resign in August 2017 over Trump's handling of a deadly white-supremacist rally in Charlottesville. Cohn, who is Jewish, was especially shaken when one of his daughters found a swastika on her college dorm room.

Trump was sharply criticized for initially saying that "both sides" were to blame. At the urging of advisers, he then condemned white supremacists and neo-Nazis, but almost immediately told aides, "That was the biggest fucking mistake I've made" and the "worst speech I've ever given," according to Woodward's account.

When Cohn met with Trump to deliver his resignation letter after Charlottesville, the president told him, "This is treason," and persuaded his economic adviser to stay on. Kelly then confided to Cohn that he shared Cohn's horror at Trump's handling of the tragedy - and shared Cohn's fury with Trump.

"I would have taken that resignation letter and shoved it up his ass six different times," Kelly told Cohn, according to Woodward. Kelly himself has threatened to quit several times, but has not done so.

Woodward illustrates how the dread in Trump's orbit became all-encompassing over the course of Trump's first year in office, leaving some staff members and Cabinet members confounded by the president's lack of understanding about how government functions and his inability and unwillingness to learn.

At one point, Porter, who departed in February amid domestic-abuse allegations, is quoted as saying, "This was no longer a presidency. This is no longer a White House. This is a man being who he is."

Such moments of panic are a routine feature, but not the thrust of Woodward's book, which mostly focuses on substantive decisions and internal disagreements, including tensions with North Korea as well as the future of U.S. policy in Afghanistan.

Woodward recounts repeated episodes of anxiety inside the government over Trump's handling of the North Korean nuclear threat. One month into his presidency, Trump asked Dunford for a plan for a preemptive military strike on North Korea, which rattled the combat veteran.

In the fall of 2017, as Trump intensified a war of words with Kim Jong Un, nicknaming North Korea's dictator "Little Rocket Man" in a speech at the United Nations, aides worried the president was provoking Kim. But, Woodward writes, Trump told Porter that he saw the situation as a contest of wills: "This is all about leader versus leader. Man versus man. Me versus Kim."

The book also details Trump's impatience with the war in Afghanistan, which had become America's longest conflict. At a July 2017 National Security Council meeting, Trump dressed down his generals and other advisers for 25 minutes, complaining that the United States was losing, according to Woodward.

"The soldiers on the ground could run things much better than you," Trump told them. "They could do a much better job. I don't know what the hell we're doing." He went on to ask, "How many more deaths? How many more lost limbs? How much longer are we going to be there?"

The president's family members, while sometimes touted as his key advisers by other Trump chroniclers, are minor players in Woodward's account, popping up occasionally in the West Wing and vexing adversaries.

- - -

Woodward recounts an expletive-laden altercation between Ivanka Trump, the president's eldest daughter and senior adviser, and Stephen K. Bannon, the former chief White House strategist.

"You're a goddamn staffer!" Bannon screamed at her, telling her that she had to work through Priebus like other aides. "You walk around this place and act like you're in charge, and you're not. You're on staff!"

Ivanka Trump, who had special access to the president and worked around Priebus, replied: "I'm not a staffer! I'll never be a staffer. I'm the first daughter."

Such tensions boiled among many of Trump's core advisers. Priebus is quoted as describing Trump officials not as rivals but as "natural predators."

"When you put a snake and a rat and a falcon and a rabbit and a shark and a seal in a zoo without walls, things start getting nasty and bloody," Priebus says.

Hovering over the White House was Mueller's inquiry, which deeply embarrassed the president. Woodward describes Trump calling his Egyptian counterpart to secure the release of an imprisoned charity worker and President Abdel Fatah al-Sissi saying: "Donald, I'm worried about this investigation. Are you going to be around?"

Trump relayed the conversation to Dowd and said it was "like a kick in the nuts," according to Woodward.

The book vividly recounts the ongoing debate between Trump and his lawyers about whether the president would sit for an interview with Mueller. On March 5, Dowd and Trump attorney Jay Sekulow met in Mueller's office with the special counsel and his deputy, James Quarles, where Dowd and Sekulow reenacted Trump's January practice session.

- - -

Dowd then explained to Mueller and Quarles why he was trying to keep the president from testifying: "I'm not going to sit there and let him look like an idiot. And you publish that transcript, because everything leaks in Washington, and the guys overseas are going to say, 'I told you he was an idiot. I told you he was a goddamn dumbbell. What are we dealing with this idiot for?' "

"John, I understand," Mueller replied, according to Woodward.

Later that month, Dowd told Trump: "Don't testify. It's either that or an orange jumpsuit."

But Trump, concerned about the optics of a president refusing to testify and convinced that he could handle Mueller's questions, had by then decided otherwise.

"I'll be a real good witness," Trump told Dowd, according to Woodward.

"You are not a good witness," Dowd replied. "Mr. President, I'm afraid I just can't help you."

The next morning, Dowd resigned.