Last week Defense Secretary James Mattis looked the commander-in-chief, just inches from his own face, in the eye. He praised our servicemen and -women, which isn’t unusual, but he was ill at ease having chosen to subtly dissent.

“Mr. President, it's an honor to serve the men and women of the Department of Defense,” said the retired Marine Corps general. “We are grateful for the sacrifices our people are making to strengthen the military, so our diplomats can always negotiate from a position of strength.” His comment came at the Trump administration’s first full Cabinet meeting, where other secretaries and the vice president indulged the president’s thirst for flattery by speaking of the “privilege” and “honor” of working for him while Chief of Staff Reince Priebus told the boss it was a “blessing” to serve his agenda.

As he approaches five months at the helm of the Pentagon, Mattis has found himself at odds with the president regarding Russia, NATO and climate change and is, at times, clearly uncomfortable. Most Republicans and Democrats believe Mattis knew precisely the challenges that awaited him when he signed on, choosing to risk personal compromise for country. But the history lover known for his allegiance to tradition, our founding principles and the liberal international order is being tested in ways he may not have anticipated.

Fortunately, despite their differences, Trump seems to have placed great trust in Mattis, one of “my generals,” as the 45th president has been known to call him, National Security Adviser H.R. McMaster and Homeland Security Secretary John Kelly. This week the administration will announce a troop increase in Afghanistan, and according to reports Mattis has decided on sending an additional 4,000 forces there in hopes of tamping down the threat rising from a resurgent Taliban. Trump rarely mentions America’s longest-ever war and has delegated authority to Mattis to set troop levels. This follows a difficult May and June in which the defense secretary was caught between reassuring our European allies and a capricious commander intent on lecturing them in person in Brussels and criticizing them on Twitter as well.

In his address at NATO headquarters, where he insisted other nations spend more on defense, Trump failed to include a reference to the U.S. commitment to Article 5. According to Politico magazine, Mattis -- along with Secretary of State Rex Tillerson and McMaster -- was “blindsided” by the president’s decision to delete language reaffirming Article 5 that was not only included in earlier drafts of the speech but had been lobbied for by the NSA and the secretaries of state and defense. The episode betrayed an unprecedented level of dysfunction within the administration to leaders throughout the world as Trump glaringly undermined his advisers’ credibility on the world stage.

Afterward, McMaster, who unlike Mattis has not avoided being dragged into politics, co-authored a Wall Street Journal op-ed with the president’s chief economic adviser, Gary Cohn, about how the president had reaffirmed his support to the alliance and Article 5 -- even though he had not. When Mattis appeared days later at a security forum in Singapore, he sought to assure allies once again of the U.S. commitment to the global order. “To quote a British observer of us from some years back, bear with us,” Mattis said. “Once we have exhausted all possible alternatives, the Americans will do the right thing. So we will still be there, and we will be there with you.”

Another suspicion of Europeans is Trump’s conspicuous silence on Russian aggression in Ukraine, a primary concern to NATO countries. Mattis is plain-spoken on the subject of a renewed bond between Russia and the United States, saying he has seen “no evidence Putin wants a positive relationship” with our country.

Another top concern at the NATO summit was the Paris climate accord, which allies lobbied Trump not to abandon. When Trump announced his decision to have the United States withdraw from it, his administration released praise from the U.S. ambassador to the United Nations, along with the secretaries of the Treasury, commerce, labor, energy, education, transportation and agriculture. Tillerson and Mattis, however, didn’t join the chorus. Not only did the latter oppose dropping out of the accord because it meant diminishing our leadership on the world stage, he also believes climate change is real and a threat to national security.

“Climate change is impacting stability in areas of the world where our troops are operating today,” Mattis wrote in responses to questions from Democratic senators on the Senate Armed Services Committee, which were published by ProPublica. “It is appropriate for the Combatant Commands to incorporate drivers of instability that impact the security environment in their areas into their planning.”

Mattis chooses exactly when he needs to speak, including when to publicly disagree with his commander-in-chief. But he rarely speaks to reporters, and has refused entreaties from Trump staff to make appearances on “Fox & Friends,” one of his boss’ favorite shows. Unlike other Cabinet secretaries and advisers who frequently praise their television-watching boss on the airwaves, Mattis doesn’t do PR.

After watching the Pentagon chief doing diplomatic cleanup with allies after the NATO summit, friends of Mattis’ remarked upon his unique balancing act. William Cohen, former secretary of defense and Republican senator from Maine, told the New York Times: “I think everyone understood that Jim is giving Trump the very best military and strategic advice possible and that he was walking a straight but fine line.”

Supporters of Mattis, across both parties, hope his patriotism will gird him through the choppy waters, and collective fingers across Washington remain crossed that he stays on the job. Yet, as one Republican senator who traveled overseas with him said recently, “It’s getting harder every week.”