Defense Secretary Jim Mattis, a softly spoken but battle-hardened former Marine, always stood in uneasy contrast with President Donald Trump, his brash businessman boss who avoided any military service.
On Thursday, after months of speculation and following Trump's stunning decision to pull out of Syria and slash troops in Afghanistan, the gulf between the two men finally grew too wide to bridge. Mattis resigned.
The 68-year-old native of Washington state, who was Trump's first cabinet pick, has spent nearly two years at the Pentagon, where he became a master of concealing from the public his true thoughts on Trump's decisions.
But his resignation letter spelled out to the world what seemed obvious to many observers: Trump's world view was irreconcilable with his own.
"My views on treating allies with respect and also being clear-eyed about both malign actors and strategic competitors are strongly held and informed by over four decades' immersion in these issues," Mattis wrote to Trump, who has sought closer ties with Russia and heaped contempt on NATO and other alliances.
"Because you have the right to have a Secretary of Defense whose views are better aligned with yours on these and other subjects, I believe it is right for me to step down from my position."
A self-described warrior who once boasted it was a "hell of a lot of fun" to shoot people, Mattis was nonetheless seen as a voice of moderation capable of reining in some of Trump's more rash impulses.
His appointment was greeted with a collective sigh of relief in Washington, following a brutal presidential campaign in which Trump vowed to upend the US-led world order.
Lawmakers of every stripe looked at the retired four-star general as a calm counterbalance to Trump.
As a highly decorated veteran, Mattis won the immediate respect of Trump, who has a fascination with all things military, dating back to his youth, when his father sent him to a private military academy in New York.
Mattis enlisted in the Marines in 1969 during the height of the Vietnam War, whereas Trump got five deferments from being drafted. And until the end, Mattis avoided the contempt Trump had publicly heaped on other of his top officials.
Trump thanked Mattis for his service, saying he would be "retiring, with distinction" -- a far cry from when he reportedly fired former secretary of state Rex Tillerson by tweet.
- Alliances and diplomacy -
Mattis believed in the established tenets of the American world order: alliances were sacred, diplomacy was better than combat, and military assertiveness required a cautious but firm hand, ready to act decisively when all else fails.
He clashed with Trump repeatedly, mostly behind the scenes, over those fundamentals.
While Trump spoke positively of working with Russian President Vladimir Putin, Mattis warned that Moscow wants to "break NATO apart" and, uncommonly, made his objections public when Trump failed to endorse the US commitment to a common defense in the Atlantic treaty organization.
He also pushed back when Trump appeared ready to leave a dangerous security gap in pursuit of a nuclear deal with North Korea.
The chasm only grew as he opposed Trump's decision to withdraw from the Paris climate change accord, decertify the Iran deal, slap tariffs on steel and aluminum, and move the US Embassy in Israel from Tel Aviv to Jerusalem.
He also quietly rejected the president's proposed ban on transgender service members, standing by a small, poorly represented part of the 2.1 million active and reserve members of the US military.
- 'Mad Dog' and 'warrior monk ' -
Trump originally latched on to Mattis for his commitment to building up the US military after years of tight budgets, and for his nickname: "Mad Dog."
A colorful commander, he earned the moniker -- which he told some he didn't really like -- with his battle-hardened swagger and the sort of blunt language Marines are famous for.
"Be polite, be professional, but have a plan to kill everyone you meet," he famously said.
But the lifelong bachelor was also known as a "warrior monk."
A scholar of warfare, he is said to have a personal library of more than 7,000 volumes, and issued required reading lists to Marines under his command, instructing them that the most important territory on a battlefield is the space "between your ears."
- Top Marine -
Mattis commanded a Marine battalion during the First Gulf War and a Marine division during the 2003 invasion of Iraq.
In 2010, he was named to head the US Central Command. That gave him authority over troops in Iraq, where he helped develop a counterinsurgency approach before overseeing the US withdrawal, and Afghanistan, where he implemented a troop surge.
An expert communicator adept at tailoring his message for his audience, whether it be a grunt in the field or a foreign dignitary, Mattis would gently cajole Trump into following orthodox US military doctrine.
Mattis last year helped persuade Trump to stay the course in Afghanistan, though Trump ultimately followed his initial instinct to try to get out.
Against Mattis's counsel, Trump ordered troops to the US border with Mexico ahead of the November election in what was widely viewed as a political stunt to show he was tough on immigration.
Then came Trump's decision this week to declare victory over the Islamic State group in Syria and pull US troops out -- which Mattis sees will leave a vacuum that could be filled by America's enemies.