WASHINGTON, DC, is a revealingly gossipy place. A favourite tale of the Donald Trump era involves a pact that the generals working for the president are supposed to have sworn. As described by ambassadors, senators and foreign-policy panjandrums, the generals have agreed that one of their number will remain in America at all times, to prevent a war being started by intemperate presidential tweets.

The details change. Sometimes, it is said, the pact involves James Mattis, the defence secretary, aligning travel with the White House chief of staff, John Kelly, a fellow retired four-star Marine general. Others say Mr Mattis is in cahoots with Joseph Dunford, a serving four-star Marine general and chairman of the joint chiefs of staff, or with H.R. McMaster, the national security adviser (an army lieutenant-general still on active service but shouldering a mere three stars). Still others insist the pact includes the secretary of state, Rex Tillerson, a former oil man and a rare civilian among the so-called “grown-ups” who run national-security policy for Mr Trump.

Mr Mattis has told aides that no such pact exists. The Economist recently travelled to South Korea with the defence secretary on the same day that General Dunford was also in Seoul, and Mr Tillerson was in Geneva. The durability of this urban legend is telling, however.

Washington grandees and foreign governments have invested extraordinary hopes in the men that Mr Trump likes to call “my generals”. The near-consensus among foreign-policy types is that Mr Trump is a thin-skinned, unpredictable and alarmingly incurious neophyte. The generals are trusted to keep the ship of state on a safe course, until the Trump-tempest blows over. Reality is more nuanced.

In line for promotion

Sighing with relief over Mr Trump’s generals does not require Washington’s elite to credit him with good judgment. The general closest to Mr Trump during his presidential campaign, Mike Flynn, failed spectacularly as his first national security adviser. The angry, crudely anti-Muslim man who campaigned with Mr Trump left old comrades shaking their heads in disbelief. Mr Flynn crashed out of office in under four weeks, after being caught fibbing about his contacts with Russian officials.

Mr Trump is widely held to have picked his best advisers on gut instinct and probably with an eye to their image as warriors from “central casting”. The president first tried to recruit a shaven-headed former Navy SEAL and retired vice-admiral, Robert Harward, to replace Mr Flynn. When he declined the offer, Mr Trump took the advice of allies including Senator Tom Cotton of Arkansas, a hardliner on Iran and other foreign-policy questions, to hire Lieutenant-General McMaster, a tough-talking counter-insurgency expert.

The president’s first choice for defence secretary, General Jack Keane, a regular contributor on Fox News, his favourite television network, turned him down citing the recent death of his wife, but recommended two four-star warrior-intellectuals, Mr Mattis and General David Petraeus. Introducing Mr Mattis as his choice to supporters in December 2016, Mr Trump revelled in the nickname “Mad Dog”, hung around the general’s neck by journalists after service in the first Gulf war, Afghanistan and Iraq. Mr Mattis dislikes the sobriquet, and was better known among his men as a “warrior-monk” who combined ferocity in combat with a taste for reading Marcus Aurelius and other Roman thinkers in his tent.

A gleeful Mr Trump described Mr Mattis as “the closest thing to General George Patton that we have”, in homage to the swaggering, snarling second-world-war commander, and promised: “Mad Dog plays no games.” Conservative media outlets swooned over Mattis-epigrams that gained fame among troops in Iraq, such as his advice: “Be polite, be professional, but always have a plan to kill everyone you meet.” It only added to Mr Mattis’s appeal on the right that he was asked to retire as head of Central Command five months early by Team Obama, who worried that his calls for aggressive containment of Iran might up-end nuclear talks.

Accepting the nomination Mr Mattis talked of the importance of allies, and of defending the country and the constitution. Just three years after retiring from the Marines, he noted that he would need a waiver from Congress to the rule that defence secretaries must have been civilians for at least seven years before running the Pentagon (the last time such a waiver was needed was for George Marshall in 1950). “He’ll get that waiver, right?” beamed Mr Trump on stage next to him. “Such a popular choice.”

As a president who inspires much amateur psychoanalysis, Mr Trump’s general-worship is routinely linked to his adolescence at a private military academy, which he has said gave him “more training militarily than a lot of the guys that go into the military” and to his avoiding service in Vietnam because of painful feet.

Fighting talk

Mr Trump gives his old warriors striking licence to disagree with him in public. After campaign-trail promises to bring back waterboarding and “a hell of a lot worse”, Mr Trump said he was “very impressed” to hear Mr Mattis explain why “a pack of cigarettes and a couple of beers” were more effective. No rebuke came in June when Mr Mattis urged an audience in Singapore to “bear with us” when Americans became put out at the burden of upholding a rules-based world order. Mr Mattis told congressional hearings that it was in the national interest to stay in the deal to freeze Iran’s nuclear programme, which the president wanted to scrap.

Other high-stakes interventions have been more discreet. Sources close to Steve Bannon, the former chief strategist to Mr Trump, confirm that he was frustrated in June when the defence secretary watered down plans for the president to confront South Korea’s new president, Moon Jae-in, over his country’s trade deficit with America. Economic nationalists in the White House urged Mr Trump to link the trade imbalance with the security offered by tens of thousands of American troops in South Korea. Mr Mattis persuaded Mr Trump to keep the two questions separate, calling this a terrible time to cast doubt on the alliance with South Korea.

Mr McMaster also clashed with Mr Bannon about troop levels in Afghanistan. The grizzled campaign strategist, who left the White House in August, challenged the general about his apparent “emotional connection” to Afghanistan, arguing that Trump voters were tired of spending blood and treasure on open-ended commitments to foreign wars. One meeting became so heated that Mr Mattis tapped Mr McMaster on the leg in an urgent warning that he should calm down, a witness says. For his part the defence secretary was left shaken by Trump aides questioning whether America has vital national-security interests in Afghanistan.

Such reports of heated debate, especially in the first months of the administration, led to breathless suggestions that the generals operate as something akin to a “deep state”, defending democratic rule from a strongman president—as if America is a richer version of the Philippines or Turkey.

When Mr Mattis talked about military power as a tool allowing diplomats to work from a position of strength, or declined to comment on breaking news until he knew more facts, pundits declared that he was obviously rebuking Mr Trump. A media cottage industry sprang up finding photographs of Mr Kelly seeming to stare at his shoes in misery, or hold his head while listening to the president, notably after becoming White House chief of staff in July following his six-month stint as secretary of homeland security.

Such reporting exasperates Mr Mattis, who sees himself as a loyal servant of the constitutional order and thus of a president who was freely elected by the American people. His duty, as described to colleagues, is to speak out when needed and to represent the views of the armed services to the commander-in-chief, but in private in order to maintain indispensable bonds of trust.

In recent weeks Mr Kelly has gone much further, deriding what he called “astounding” press reports that he sees his role as controlling the president. As chief of staff his job is to control only the flow of information to the president, he said in October. A sharper row followed after Mr Kelly defended Mr Trump against allegations of mishandling a telephone call to the widow of a soldier killed in action.

After poignantly describing how he learned of the death of his own son in combat, Mr Kelly then attacked a Democratic congresswoman critical of Mr Trump’s call to the bereaved woman, falsely accusing her of exploiting an earlier fatal tragedy for political gain. Mr Kelly then startled the White House briefing room by suggesting that many journalists do not even “know anyone who knows anyone” in the armed forces and offering to take questions from reporters with a connection to a bereavement in war.

Mr Kelly’s overtly partisan defence of his president surprised many civilians. But his voicing of conservative political views—followed up a few days later with an odd defence of a Confederate civil-war general, Robert E. Lee, as an “honourable man”—also dismayed his brothers in arms. A former colleague calls Mr Kelly’s press conference a “very sad moment” which showed the dangers of allowing war service to become politicised and “really broke my heart”.

Officer material

Attitudes to global openness increasingly divide Americans. They also divide Mr Trump, a man who does not understand why anyone would want to visit dangerous places, from his beloved generals, all of whom came of age in far-off theatres of war and survived by studying alien codes of behaviour. Yet there are differences between the generals, too. It is said that Mr Kelly’s years at Southern Command, overseeing crime-ridden Central America, left him readier to haul up drawbridges against a wicked world.

As for Mr Mattis, he let his views show briefly when talking to young troops on a parade ground in central Seoul on October 27th, after a helicopter flight from the (heavily fortified) demilitarised zone that cuts the Korean peninsula in two. Asked about American forces bringing families to live in South Korea, the defence secretary conceded that they live “within range” of North Korean artillery. But having Americans live alongside Koreans, who watched their democracy emerge from a bloody war, provides “an awful lot of our strength in the alliance,” Mr Mattis said.

Mr Trump takes a transactional view of alliances. Visiting Seoul on November 7th he thanked South Korea for buying American arms, saying: “We make the finest equipment in the world, and you’re buying a lot of it, and we appreciate that.”

Senior uniformed and civilian figures do see upsides to having generals serve in the Trump administration. In a polarised, short-termist political environment, modern commanders stand out for their impatience with ideology, for taking the long view and for their devotion to the free competition of ideas. That is no surprise, for it was ideological certainties that led to the botched occupation of Iraq after the overthrow of Saddam Hussein in 2003.

This generation of generals has seen a lot of combat. A long-time colleague notes that after retiring from the Marines, Mr Mattis spent months on a cross-country road trip, quietly visiting the families of troops killed on his watch. He is not anti-war, but is conscious of war’s limits. One of his favourite quotes, from Will Rogers, a newspaper columnist in the 1920s, notes that many foreigners are more comfortable with an imperfect government of their own choosing than with a perfect one imposed by American Marines. Mr Mattis has called his countrymen “an idealistic people bound by pragmatism”.

On the frontline

Many modern generals are impatient with partisans trying to start culture wars about such issues as transgender troops or sexual harassment in the ranks, asking instead what policies promote discipline and “lethality”. Those generals are as interested in the power of America to inspire as to intimidate, says Michèle Flournoy, a former under-secretary of defence who declined an offer to be Mr Mattis’s deputy, citing discomfort with the Trump agenda. “These are people who know the cost of war. They are the first to say, we can use coercive means but it is better to use them to back up diplomacy,” she says.

The military chain of command teaches officers devotion to institutions larger than any one individual’s whim, says Robert Tyrer, a former chief of staff to William Cohen, who as defence secretary worked closely with Mr Mattis in the 1990s. It teaches officers to think about “a broader sense of national purpose” dating back to the start of the American experiment 240 years ago, rather than one measured in four-year electoral cycles.

The commander-in-chief likes a man in a uniform

The armed forces teach high-flying officers Washington’s ways, notes Mr Tyrer, giving Mr Trump’s generals more experience of government than many in his team of outsiders. As a colonel, Mr Mattis served as executive secretary to two defence secretaries, a co-ordinating post “at the centre of the central nervous system of the department”, in Mr Tyrer’s words. The younger Mr Mattis stood out for being unusually reflective and for “reading Thucydides at the weekend”. Mr Kelly was a Marine Corps liaison to Congress and in 2011-12 the senior military assistant to the defence secretaries Robert Gates and Leon Panetta.

Partisan swings of the pendulum have also left some high-ranking commanders wary of siding with any one party or faction. Privately, many disliked micromanagement by Mr Obama and aides who seemed to think of American interventions as a destabilising menace. They see a potentially useful energy in Mr Trump’s impatience and willingness to press allies to do more. In their most optimistic moments, they can make this president sound like an accidental Ronald Reagan, ready to shake up stale assumptions and press allies to step up. At other times, senior defence folk chafe at Mr Trump’s distinctly un-Reaganish scorn for American exceptionalism and apparent belief that he has little or nothing to learn from predecessors.

Mr Panetta, a former CIA director as well as defence secretary, White House chief of staff and congressman, worries that generals lack much experience of the horse-trading side of politics. Watching his former aide, Mr Kelly, under fire after taking to the airwaves to defend Mr Trump, Mr Panetta offers the thought that: “If you’re a good chief of staff, one fundamental role is to tell the president ‘no’.”

For all the risks of a national-security team that is so heavily weighted towards military experience, Mr Panetta believes that Mr Trump’s generals are “the best hope we have to restrain this president and to keep him on a more traditional foreign-policy path”. Such talk alarms Mr Bannon, now back running Breitbart, his hard-right news operation. He remains a fan of Mr Kelly’s grasp of the national interest and the importance of strong borders, to the point of telling the president, with whom he speaks regularly, that the chief of staff would make a good secretary of state after Mr Tillerson.

He credits Mr Mattis with crafting a plan of “annihilation rather than attrition” against the extremists of Islamic State, but adds: “That being said, I’m not quite sure he has totally bought into the Trumpian worldview, that America is not going to underwrite the security of the whole post-war rules-based international order.”

Mr Bannon urges Mr Trump to seek generals who share his “America First” vision. He has urged Mr Trump to study the example of Abraham Lincoln and his generals. “Lincoln was sold on the fact that the generals were experts, and had all the plans for winning the civil war. But [to win] he had to find Grant and Sherman, who were prepared to execute his strategy, which was to burn the South down.”

Marching to a different tune

Such whiffs of raw politics are just what worries former commanders like Admiral Mike Mullen, chairman of the joint chiefs of staff from 2007 to 2011. Generals have served in government before, including Brent Scowcroft and Colin Powell at the National Security Council. Mr Powell and Alexander Haig both served as secretary of state, while Mr Haig was a White House chief of staff.

This time feels different, says Mr Mullen, both because there are so many generals in high office, and because “the country takes such comfort from them being there.” In his experience, military careers may prepare generals for the political world, with a small “p”—hearings on Capitol Hill or talks with foreign counterparts. But the world of Politics with a capital “P” is something more alien, and perilous. In a speech in October, Mr Mullen questioned whether it is right to depend “on retired generals for the stability of our citizenry”.

It is better to have good generals than bad men in powerful jobs. But no one cabinet secretary or aide can save the government from calamity. The American chain of command allows for much robust debate. But the toughest generals can argue only for so long, notes Mr Mullen. “Then the president makes a decision, and you march off and execute.”

This article appeared in the Briefing section of the print edition under the headline "Counsel of warriors"