WASHINGTON — John Bolton, President Donald Trump's famously hawkish national security adviser, could not have been enthusiastic when his boss crossed into North Korean territory last weekend to make a bit of history with the leader of the Pyongyang regime, Kim Jong Un.

For years, Bolton has warned against conciliatory gestures or negotiations with North Korea. Two months before he took his current job, Bolton argued in an op-ed for a preemptive strike on North Korea based on what he called an "imminent" threat.

Now Trump's latest diplomatic gambit with North Korea has raised fresh questions about the influence of his national security adviser, who has appeared out of sync with the president in recent weeks, particularly when it comes to how to handle Pyongyang.

When the president stepped into North Korean territory briefly alongside Kim Jong Un over the weekend, Bolton was conspicuously absent, holding talks 1,200 miles away in the capital of Mongolia, Ulaanbaatar.

While Bolton was on his previously scheduled trip to Mongolia, a fierce critic who has painted him as a warmonger — Fox News pundit Tucker Carlson — was on hand for the president's rendezvous with the North Korean leader.

A day after Trump's unprecedented walk across the demilitarized zone into North Korean territory, Bolton pushed back against a report in the New York Times that said the administration was considering scaling back its demands on Pyongyang and accepting a freeze on North Korea's production of nuclear material instead of a full dismantling of its arsenal.

"Neither the NSC staff nor I have discussed or heard of any desire to 'settle for a nuclear freeze by NK,'" Bolton tweeted. He called the report "a reprehensible attempt by someone to box in the President."

Trump, who as a candidate promised to extract America from wars overseas, has openly acknowledged that he and Bolton do not see eye to eye at times, but he has insisted he retains confidence in his national security adviser.

"John Bolton is doing a very good job but he takes a generally tough posture," Trump said last month. He called Bolton a "hawk," and added, "I have other people that don't take that posture, but the only one that matters is me."

Bolton's trip to Mongolia had been planned a month before the impromptu meeting with Kim, a person familiar with the planning said, and he stopped in Jerusalem to meet with Israeli and Russian officials. Bolton chose to go to Mongolia instead of the DMZ because the country has "a critical bilateral relationship that the U.S. is looking to deepen across economic and military ties," this person said.

A senior official insisted Bolton's view was not out of step with Trump's on North Korea. The president remains committed to an agreement that would require Pyongyang to give up its entire nuclear weapons program in return for a lifting of economic sanctions, instead of an incremental, step-by-step negotiation, the official told NBC News. "The policy on North Korea is what it has been and continues to be, the big deal. Hand over all of it," said the official, who was not authorized to speak on the record.

It was the State Department and Stephen Biegun, the U.S. envoy to North Korea, who have sometimes moved beyond the president's position, the official said, citing the February summit in Hanoi that ended abruptly without an agreement. "The last time the State Department got ahead of the President he walked from Hanoi."

In May, hours after Bolton told reporters North Korea had violated United Nations resolutions with a short-range missile test, Trump played down the episode.

"North Korea fired off some small weapons, which disturbed some of my people, and others, but not me," Trump tweeted. "I have confidence that Chairman Kim will keep his promise to me."

It's not the first time the president has publicly contradicted senior members of his administration. Trump blindsided former Defense Secretary James Mattis, former Secretary of State Rex Tillerson and others with tweets and remarks that ran counter to previously stated policies.

"It's kind of a way of publicly putting Bolton in his place," one source close to the White House said. "He kind of takes glee in doing it publicly."

According to three sources with close ties to the administration, friction between Trump and Bolton worsened in late May over Iran.

Outside advisers and supporters told Trump he was being dragged into a confrontation with Iran and alleged his aides were moving ahead without fully consulting him, the sources said. The president came away angry and ready to question Bolton.

"There definitely are tensions," one of the sources said of Trump's and Bolton's relationship.

The dynamic between the two men ebbs and flows, with Bolton at times favored by Trump and at other times a source of irritation, the sources said. Bolton's status is not helped by the fact that he has made few allies inside the administration.

Nevertheless, the president did not appear to be ready to sack Bolton, the sources said.

While Bolton is at odds with some other members of the administration over North Korea, he and Secretary of State Mike Pompeo are mostly in agreement on pursuing a tough line with Iran, current and former officials said. But Pompeo enjoys a closer rapport with the president, and is more adept at adjusting to Trump's view and pulling back on a course of action that makes the president uncomfortable, current and former officials said.

The White House National Security Council did not respond to requests for comment.

James Stavridis, former NATO supreme allied commander, said that under previous administrations, it would have been "unthinkable" for a president and a national security adviser to air their disagreements in public.

"Publicly it sends a very bad signal, both to our allies and also it encourages our opponents," the retired admiral told NBC's Andrea Mitchell. "Kim is thinking, 'Wow, this is terrific.'"

Despite Trump's wariness of military confrontation, Bolton has had a substantial impact on the administration's policies, helping to push through harsh economic sanctions on Iran and the Maduro regime in Venezuela, former officials and experts say.

But Trump is reportedly disappointed that the sanctions have not spelled the end of the Maduro regime as quickly as Bolton and his team expected.

Last week, Bolton played a role in Trump's decision to impose yet more sanctions on Iran, targeting Supreme Leader Ayatollah Ali Khamenei and other senior Iranian officials days after Tehran downed a U.S. drone.

People close to the national security adviser downplayed the significance of any differences between Bolton and the president, saying Bolton's not worried. Trump "likes people who have different opinions," one of them said.

In an interview with the New Yorker magazine published in April, Bolton said he accepts that his view does not always prevail in the White House.

"You have to know in advance the president's views are not always yours. When you enter government, you know that you aren't going to win everything."

Stavridis said the president's treatment of Bolton could force the national security adviser to question his future in the administration.

"He's got to start seeing that self-respect light flickering a little bit, flashing yellow," Stavridis said.

"I think he has to figure out a way to close the gap with his boss or look for other opportunities to serve," he said.

First published by NBC News. Cartoon by Dave Granlund.

Dan De Luce is a reporter for the NBC News Investigative Unit.

Carol E. Lee is an NBC News correspondent.

Andrea Mitchell is NBC's chief foreign affairs correspondent.