Defense Secretary Jim Mattis was in Norway over the weekend, a short hop from the site of President Trump’s Monday summit with Russian President Vladi­mir Putin in Helsinki. But often it seemed as though Mattis was inhabiting a distant world.

For much of the past week, amid Trump’s upbraiding of the NATO allies, his undermining of the British prime minister and his courting of Putin, Mattis has been nearly invisible. On the rare occasions he has spoken, the Pentagon chief did not refer to his boss.

Mattis traveled with Trump to the NATO summit in Brussels but remained offstage when Secretary of State Mike Pompeo and national security adviser John Bolton joined Trump during the president’s impromptu news conference.

When he did surface, Mattis mentioned the president (of Croatia).

“It was a very good discussion,” he said of their meeting Friday at the U.S.-Adriatic Charter summit in Zagreb, the capital of Croatia. “I’ll just leave it at that.”

He twice quoted Vice President Pence on the importance of America’s commitment to its Adriatic allies. Trump’s name did not come up.

Even as senior Pentagon officials insist they have never been more united, Mattis often seems to be having a different conversation with allies than Trump. His defense strategy, published in December, stresses the importance of alliances, especially in Europe, and orders the U.S. military to ramp up its capabilities to counter the threat posed by Russia.

“Everyone can understand there’s very little upside for him to be seen in public, because even if he says reassuring things he’s going to be at variance with the president,” said Derek Chollet, a former senior Pentagon official now at the German Marshall Fund of the United States.

Dana White, chief Pentagon spokeswoman, said Mattis had long said that Europeans had to be as committed to the continent’s defense as Americans were. “For more than a year, the secretary has clearly communicated the President’s guidance and today every NATO member is spending more on defense,” she said.

But Chuck Hagel, a defense secretary for President Barack Obama, said Trump’s statements — disparaging of NATO and alliance partners one moment only to lavish them with praise the next — put Mattis in an almost untenable position

“He can’t dismiss what the president said, so he’s got to finesse it,” Hagel said.

The defense secretary has, at times, sought to “finesse it” by ignoring in public any presidential statements that seem to run counter to Mattis’s overall approach to the military. In Croatia, he touted “our shared democratic values” and the importance of “the rules-based international order,” a phrase that senior Trump administration officials tried to have struck from a communique at the Group of Seven summit in Canada last month. Trump was the only world leader who chose not to sign the group statement.

And Mattis dismissed out of hand the notion that the most tumultuous NATO summit in decades had been at all unusual. “A very hearty discussion,” he said of the two days of meetings with allies in Brussels.

He then mocked a report from NBC News suggesting that senior military officials were conducting damage control with allies in the aftermath of the summit. “That was fascinating,” he said. “I love reading fiction.”

Trump and Mattis’s differences were even starker on the subject of Russia and Putin. “I think I’d have a very good relationship with President Putin if we spend time together,” Trump said ahead of his meeting in Helsinki

Mattis, by contrast, described Russia and its leader as a force seeking “to undermine the fabric of nations . . . whether through false news reporting, economic strictures and interventions.”

“They are not seen as helpful,” he told reporters on his way to Norway on Friday. “That would be probably the most polite way to describe it.”

Despite Trump’s statements in Brussels and Britain, Mattis has a positive story to tell about NATO, said current and former defense officials.

Mattis is “winning the war” in terms of securing support for Pentagon initiatives, such as a new NATO training mission in Iraq, which will relieve pressure on U.S. forces there, Chollet said. The alliance also committed last week to a Mattis-backed proposal that ensures it will be able deploy 30 mechanized battalions, 30 air squadrons and 30 combat vessels within 30 days of an order. The rapid deployments are seen as essential to counter any Russian aggression on NATO’s eastern periphery.

And he praised the allies for their commitment to spend 2 percent of their gross domestic products on defense by 2024, never mentioning the 4 percent goal raised by Trump at NATO, a proposal that injected another element of uncertainty into the discussions.

Mostly, though, Mattis continued to strike a posture that was the tonal opposite of his boss. “I reiterate that I am here to listen,” he said in Zagreb. “You live here, and each of you knows this neighborhood best.”