One of Mr. Mattis’s first moves as defense secretary was to phone the NATO secretary general to assure him that he strongly supported the alliance that Mr. Trump has criticized as “obsolete.” Mr. Mattis will fly to Asia next week on a trip to allay concerns in Japan and South Korea that the United States might abandon longstanding commitments to their security.

A week after that, Mr. Mattis is expected to make another reassurance trip — this one to Europe — to meet with counterparts at NATO in Brussels and then at a security conference in Munich.

Lawmakers and even some members of the military are hoping that Mr. Mattis can also serve as a counterweight on some of the new administration’s more hard-line positions. In a classified operations center at one Special Operations headquarters, a photo of Mr. Mattis is taped to a board with various captions written underneath. On Thursday morning, the caption read: “Watch over us.”

During his first visit to the Pentagon, Mr. Trump will conduct a ceremonial swearing-in of Mr. Mattis and is expected to sign the new directives and have a short meeting with the Joint Chiefs of Staff.

Mr. Trump and Mr. Mattis appear to have some positive chemistry. They were seen chatting warmly on the reviewing stand during the inaugural parade. The new commander-in-chief relishes referring to “Mad Dog” Mattis at every opportunity, even though the retired general does not like that nickname and insists it is no more than a media invention.

And while they agree on the need for more military spending, some of the defense secretary’s views are at odds with his new boss, including his skepticism of Russia’s intentions, his traditional support for allies and flat opposition to the use of torture in interrogating terrorists.

The day before Mr. Mattis came to work at the Defense Department, he issued a statement to the Pentagon work force that cast the United States as a bulwark of the international order and the guardian of important alliances. In contrast to the “America First” oratory emanating from the White House, Mr. Mattis vowed that the Pentagon would work “for an America that remains a steady beacon of hope for all mankind.”