A forthcoming book by journalist Bob Woodward describes a series of episodes involving President Trump and Defense Secretary Jim Mattis. (Mandel Ngan/AFP/Getty Images)

An explosive new account of friction between President Trump and Defense Secretary Jim Mattis threatens to impair their relationship and undermine the retired Marine general’s role as an influential voice for foreign policy continuity.

A forthcoming book by veteran journalist Bob Woodward, sections of which were described Tuesday by The Washington Post, recounts a series of episodes involving Mattis and Trump. Woodward writes, for example, that after a National Security Council meeting on the Korean Peninsula, Mattis said the president had the understanding of “a fifth- or sixth-grader.”

Mattis vigorously denied insulting the president and described the exchanges in the book as “a product of someone’s rich imagination.” On Wednesday, Trump said Mattis was “doing a fantastic job” and would stay in his position.

But the reporting from one of America’s most respected journalists nevertheless adds urgency to a question that has been building across Washington in recent months: How long will Trump remain comfortable with a Pentagon chief with a reputation for keeping him in check?

The book comes at a delicate moment in the Trump presidency, as the White House struggles to project its message of success in a year marked by personnel drama, fallout from the Russia probe, and a series of presidential spats with everyone from TV stars to world leaders.

Retired Adm. Jim Stavridis, who served alongside Mattis and White House Chief of Staff John F. Kelly, another retired general who is depicted in the book making disparaging comments about Trump, said the reporting added new credence to a damaging portrait of the presidency.

“We must face the reality that there is real international danger ahead as a result of such confusion and acrimony at the top of our national security structure,” said Stavridis, who is now an operating executive with the Carlyle Group.

Since taking over at the Pentagon 19 months ago, Mattis has cut a sharp contrast to his unpredictable commander in chief. He has quietly made a traditionalist mark on the administration’s foreign policy, talking the president out of embracing torture and securing his reluctant support for operations in Syria and Afghanistan.

Again and again Mattis has walked back provocative statements by Trump, as the president seemed to question the U.S. allegiance to NATO and commitment to keeping troops in South Korea. All that has made Mattis a favorite not just of lawmakers from both parties but also of allied nations struggling to make sense of the Trump era.

“What he’s trying to do is help Trump think through how his conflicting and somewhat impulsive instincts might translate into policy,” said Michael O’Hanlon, a defense scholar at the Brookings Institution.

Mattis has managed to avoid the public flaps that sabotaged Trump’s dealings with senior leaders such as former secretary of state Rex Tillerson, who reportedly called the president a “moron.” Mattis has kept a studiously low profile, appearing only rarely on television, sidestepping political controversy and telegraphing his deference to the president.

That restrained demeanor makes the picture presented by Woodward all the more striking, adding new heft to previous reports of Mattis correcting or containing his boss.

When Syrian President Bashar al-Assad unleashed chemical weapons on Syrians in 2017, Trump told Mattis he wanted to assassinate the dictator, Woodward writes.

Mattis concurred but then told an aide: “We’re not going to do any of that,” according to the book.

While Mattis denied in his statement that he had said “contemptuous words” about his boss, he did not dispute the scene describing his reaction to Trump’s outrage at Assad.

No matter their origins, the interactions described by Woodward are likely to fan friction between White House and Pentagon officials following months of speculation about a growing distance between Mattis and Trump. While the Pentagon has rejected the idea that policy differences have fueled any discord, State Department officials denied similar reports related to Tillerson until the day Trump fired him in a tweet.

It is Trump’s nature to stew over insults or perceived insults and to nurse grudges against people, including, and perhaps especially, his own staff. For example, after it was reported that Tillerson had disparaged Trump, the relationship between the two men soured and never recovered.

While Mattis has sought to stay out of White House drama, he has occasionally made comments that some have seen as a subtle rebuke to Trump’s leadership, including in the wake of the racially charged 2017 confrontations in Charlottesville.

He also made joking nods to the turmoil of the day. Speaking at the Marine Corps Heritage Foundation’s 2018 awards dinner in April, Mattis recognized Kelly in the crowd and noted with a smile that he was “chief of staff of the White House — God bless you.” The line drew laughs and applause.

Mattis’s fate is of intense interest not just to allies in Congress but also to those in Europe. Diplomats and policymakers there had mixed reactions to Woodward’s revelations. Some said they feared that Mattis’s geopolitical expertise was one of the few barriers stopping Trump from ripping up the old transatlantic fabric and building an alliance of global strongmen.

Others, though, said that they had already factored strained relations between the Pentagon and the White House into the way they deal with Washington and that the revelations in the book probably would not change Trump’s approach to national security issues.

“Mattis knows and understands and has the experience and humility to pick his battles,” said one senior European foreign policy official, speaking on the condition of anonymity to candidly discuss fears about the behavior of an ally. “It is not clear to me that a lesser man or woman could keep DOD’s head above water. So in a macro sense, Mattis is important as an experienced and balanced adult who knows that defense of Europe is in the U.S.’s interest.”

An E.U. foreign minister, also speaking on the condition of anonymity, said their nation had embraced the turmoil of its dealings with its biggest transatlantic partner.

“Frankly, we are getting used to the new normal,” the minister said.

Michael Birnbaum in Brussels, Karla Adam in London and Philip Rucker in Washington contributed to this report.