Some of the freshest details in the book involve Mr. Mattis, a retired Marine Corps general who has been viewed as an anchor in Mr. Trump’s cabinet. Mr. Woodward portrays Mr. Mattis as frequently derisive of the commander in chief, rattled by his judgment, and willing to slow-walk orders from him that he viewed as reckless.

In the North Korea meeting, during a period of high tension with the country’s leader, Kim Jong-un, Mr. Trump questioned Mr. Mattis about why the United States keeps a military presence on the Korean Peninsula. “We’re doing this in order to prevent World War III,” Mr. Mattis responded, according to Mr. Woodward.

In April 2017, after President Bashar al-Assad of Syria launched a chemical attack on his own people, Mr. Trump called Mr. Mattis and told him that he wanted the United States to assassinate Mr. Assad. “Let’s go in,” the president said, adding a string of expletives.

The defense secretary hung up and told one of his aides: “We’re not going to do any of that. We’re going to be much more measured.” At his direction, the Pentagon prepared options for an airstrike on Syrian military positions, which Mr. Trump later ordered.

Mr. Mattis issued his own statement denying he ever used the “contemptuous words” that Mr. Woodward attributed to him. “While I generally enjoy reading fiction,” he said, “this is a uniquely Washington brand of literature, and his anonymous sources do not lend credibility.”

Mr. Woodward’s reporting adds another layer to a recurring theme in the Trump White House: frustrated aides who sometimes resort to extraordinary measures to thwart the president’s decisions — a phenomenon the author describes as “an administrative coup d’état.” In addition to Mr. Mattis and Mr. Cohn, he recounts the tribulations of Mr. Kelly and his predecessor, Reince Priebus, whose tensions with Mr. Trump have been reported elsewhere.

Mr. Cohn, Mr. Woodward said, told a colleague he had removed the letter about the Korea free trade agreement to protect national security. Later, when the president ordered a similar letter authorizing the departure of the United States from the North American Free Trade Agreement, Mr. Cohn and other aides plotted how to prevent him from going ahead with a move they feared would be deeply destabilizing.