The book, Call Sign Chaos, will be published next week. The Guardian obtained a copy. In it, Mattis avoids direct criticism of his former boss but offers some pointed comments that will probably be seized on by opponents of the president.

The retired US marine corps general recalls being surprised in November 2016 when he was called by the then vice-president-elect, Mike Pence, and asked to meet Trump to discuss the job of defense secretary.

Mattis describes being driven to the Trump National Golf Club in Bedminster, New Jersey, and having an amiable meeting.

But, he notes: I figured that my strong support of Nato and my dismissal of the use of torture on prisoners would have the president-elect looking for another candidate.

Trump had voiced support for torture during the 2016 campaign, suggesting he might order the military to break the law on interrogation tactics, including using waterboarding.

Mattis apparently managed to change Trumps mind. The president told the New York Times: [Mattis] said: Ive always found, give me a pack of cigarettes and a couple of beers and I do better with that than I do with torture. And I was very impressed by that answer.

The pair also disagreed over Nato, which Trump described as obsolete, the Iran nuclear deal, negotiations with North Korea and the creation of a space force. Mattis sudden resignation last December came after Trump moved to withdraw all US troops from Syria.

The book offers insight into the riddle of why some mainstream political and military figures have agreed to serve under a president widely seen as dangerous, dishonest and a threat to national security.

Mattis writes: In my view, when the president asks you to do something, you dont play Hamlet on the wall, wringing your hands. To quote a great American athletic companys slogan: Just do it. So long as you are prepared, you say yes.

Mattis offers a brisk but telling explanation of his departure: When my concrete solutions and strategic advice, especially keeping faith with allies, no longer resonated, it was time to resign, despite the limitless joy I felt serving alongside our troops in defense of the constitution.

Unlike in the past, where we were unified and drew in allies, currently our own commons seems to be breaking apart, he writes.

What concerns me most as a military man, coming out of a diverse yet unified culture, is not our external adversaries; instead, it is our internal divisiveness.

He adds: We are diving into hostile tribes cheering against each other, fueled by emotion and a mutual disdain that jeopardizes our future, instead of rediscovering our common ground and finding solutions.

Many commentators blame Trump for stoking division, particularly along racial lines. Mattis, who has returned to the Hoover Institution thinktank at Stanford University in Palo Alto, California, does not identity the president as the source of such rancor.