WASHINGTON — Where some see Defense Secretary Jim Mattis distancing himself from President Donald Trump on North Korea and other big issues, Mattis sees “someone’s rather rich imagination” at work creating a conflict where he insists none exists.

“I’ve seen this now for months,” Mattis said, referring to reports that he is at odds with the commander in chief.

In an impromptu exchange with reporters at the Pentagon on Thursday, Mattis was asked about interpretations of comments he made Wednesday after Trump tweeted that talking to North Korea “is not the answer.” Shortly after the tweet, a reporter asked Mattis whether the U.S. was out of diplomatic solutions. He replied, “No, we’re never out of diplomatic solutions.”

Some viewed this as contradicting, or even defying, Trump.

“It was widely misinterpreted,” Mattis said. He said he agreed with Trump that the U.S. should not be talking to North Korea now, after it fired a ballistic missile over Japanese territory, which Mattis called “a reckless, provocative act.” There remain diplomatic avenues to pursue in the interest of avoiding war, including additional economic sanctions, Mattis said.

“There is no contradiction at all there,” he said. “No disagreement with the president.”

He was clearly annoyed by persistent reports of rifts, or at least differences in views, with Trump.

“Right now, if I say six and the president says half a dozen, they’re going to say I disagree with him,” he said.

In fact, Mattis himself has acknowledged differences with Trump, and he noted two of these Thursday. He recalled that when Trump interviewed him for the Pentagon job after the election, they disagreed on the value of NATO and the utility of torturing terrorist suspects. In both cases, Mattis seemed to persuade Trump to change his view.

“This is not a man who is immune to being persuaded if he thinks you’ve got an argument,” he said.

Early in his tenure at the Pentagon, following assertions by Trump that journalists are “the enemy of the American people,” Mattis said he does not view reporters as adversaries and sees value in the skeptical view they offer.

More recently, Mattis and Secretary of State Rex Tillerson have made remarks seen by some as rebuffing Trump. Mattis, for example, was seen as splitting with the president during remarks to American troops while visiting Jordan last week.

He told the troops to “hold the line” until the rest of the country gets back to treating each other with civility. Some interpreted the remarks as a critique of Trump’s leadership following recent violence in Charlottesville, Virginia.

Mattis said he was simply striking a theme of unity that Trump himself had voiced just hours earlier in a speech on Afghanistan. Trump had urged Americans to follow the example of members of the military, in whom “we can find the inspiration our country needs to unify, to heal, and to remain one nation under God. The men and women of our military operate as one team, with one shared mission, and one shared sense of purpose.”

Mattis said this was the message he was trying to echo in his off-the-cuff remarks in Jordan, which were recorded by someone in his audience and uploaded to the internet.

“I literally can take the president’s themes and use them and I’m still seen as at odds with the president,” he said. “I think this is more someone’s rather rich imagination.”