And even if Mr. Mattis is not a registered Democrat, he is viewed more warmly by Democrats than any other member of the Trump administration. Mr. Mattis famously clashed with President Barack Obama over Iran policy when he was the head of United States Central Command, but he had a good relationship with Hillary Clinton and was viewed by many as a likely candidate for defense secretary had she won the 2016 presidential election.She didn’t, and he became defense secretary anyway, initially embraced by Mr. Trump, whom Mr. Mattis only met for the first time at his job interview during the transition. The two men got off to a great start, with Mr. Mattis talking Mr. Trump out of torturing detainees and advocating on behalf of American alliances around the world.But in recent months, strains have started to show, in part because, aides say, Mr. Trump has come to resent the narrative of Mr. Mattis as the only adult in the room in a chaotic White House.What’s more, the decision by John R. Bolton, the national security adviser, to appoint Mira Ricardel as his deputy was viewed by many at the Pentagon as a direct affront to Mr. Mattis, who clashed with Ms. Ricardel when she served as a Pentagon transition official for the new administration.The president’s decision to publicly air differences with his defense secretary is bound to make Mr. Mattis’s job even tougher, especially as he goes about the business — as he is doing this week — of trying to represent the Trump administration on the world stage.Mr. Mattis pointed to his trip to Vietnam, where he will be seeking to clear up some of the last remaining issues of the Vietnam War, and Singapore, where he will be meeting with Asian defense ministers, as proof that he remains part of Mr. Trump’s national security team.“You can see right here, we’re on our way, we just continue doing our job,” he said.But the counterparts he will be meeting here may have questions of their own about whether the defense secretary is on the same page as his boss. The fact is that Mr. Trump has the final say on a wide range of issues, from how to handle the deteriorating relationship with China, which Mr. Mattis is trying to mend, to whether the United States should continue to suspend military exercises in the Korean Peninsula as a sweetener to North Korea, a concession that Mr. Mattis opposed.