© Erin Schaff/The New York Times John R. Bolton, the national security adviser, has never clicked personally with President Trump, according to other advisers to the president.

WASHINGTON — President Trump was grousing about John R. Bolton, his national security adviser, at his Florida club not long ago. Guests heard the president complaining about the advice he was getting and wondering if Mr. Bolton was taking him down a path he did not want to go.

For a president who runs hot and cold on nearly all of his advisers, private carping may not mean that much. But in recent days, the disconnect between Mr. Trump and his national security adviser has spilled over into public, sowing confusion around the world about America’s foreign policy, particularly on matters of war and peace.

The disparity was on stark display during Mr. Trump’s four-day visit to Japan that ended Tuesday after he contradicted Mr. Bolton on high-stakes confrontations with both Iran and North Korea. The president declared that, unlike his national security adviser, he was not seeking regime change in Iran and he asserted that, contrary to what Mr. Bolton had said, recent North Korean missile tests did not violate United Nations resolutions.

Sign Up For the Morning Briefing Newsletter

In playing dove to Mr. Bolton’s hawk, Mr. Trump may be simply keeping adversaries off balance, as some backers maintained. But questions about his relationship with his chief foreign policy coordinator have profound implications for the president as he tries to manage standoffs in Asia, the Middle East and South America without alienating the United States’ allies.

“As the trip to Japan reminds us, these breakdowns and interpersonal dramas happen when a lot of other things are going on in the world,” said John Gans, a former Pentagon official and the author of “White House Warriors,” a new history of the National Security Council and its role in military conflict.

Mr. Gans, who is critical of how Mr. Bolton has changed the way policy is decided, said that unlike domestic issues, the business of foreign affairs does not stop because of a political spat. “That’s why all this interpersonal drama after Bolton broke the process is so dangerous,” he said. “The question right now is who is filling the gap and how.”

Related video: Trump 'not bothered' by North Korean missile launches (Associated Press)

The president’s supporters, however, said too much was being made of the differences. Mr. Trump has often surrounded himself with advisers who do not agree and encourages the debate, they said. If the disparate messages keep Iran, North Korea and Venezuela uncertain of how far the United States will go, they added, that can work to Mr. Trump’s benefit.

“Bolton is useful for him,” said Mark Dubowitz, the chief executive of the Foundation for Defense of Democracies, a group that advocates a tough approach to Iran. “Bolton is the uber hawk from central casting. The North Koreans hate him. The Iranians hate him. Both regimes have gone after him — I think Bolton loves it, and I think the president does, too. It opens up some diplomatic space for him to go back and forth between a very hard-line position and holding talks.”

Mr. Trump chose Mr. Bolton as his third national security adviser last year, selecting a longtime conservative voice who shared the president’s penchant for blunt talk and who regularly defended him on Fox News. Mr. Bolton previously served in multiple Republican administrations, most recently as President George W. Bush’s ambassador to the United Nations.

With his trademark bushy mustache and sharp tongue, Mr. Bolton, 70, has been a leading national security hawk for years, making a name for himself as a supporter of the Iraq war, a champion of American sovereignty and an unrelenting critic of international organizations and arms control treaties he deems tilted against the United States. After leaving Mr. Bush’s administration, he harshly criticized the 43rd president for going soft in negotiations with North Korea.

Mr. Trump picked Mr. Bolton in part as a reaction against the narrative that the current and retired generals in his administration were really running things, and in part to find a polar opposite of Mr. Bolton’s predecessor, Lt. Gen. H.R. McMaster. It also helped that Mr. Bolton had the support of Sheldon G. Adelson, the casino mogul and Republican financier who has been a key backer of the president.

Unlike General McMaster, Mr. Bolton figured out how to brief Mr. Trump in a more effective way, according to administration officials, but the two have never bonded on a personal level, which is so important in this White House. Mr. Trump is not fond of Mr. Bolton, according to a half-dozen advisers and associates, and he makes no secret of it in private.

And in some fundamental ways, the two diverge sharply over their approach to the world. Mr. Trump came to office vowing to pull out of overseas wars and has made diplomacy with North Korea a signature initiative. Mr. Bolton has been an advocate of military action and an opponent of negotiations with North Korea.

In private, Mr. Trump has made fun of his adviser’s militant reputation, suggesting that he was the one restraining Mr. Bolton rather than the other way around. “If it was up to John, we’d be in four wars now,” one senior official has recalled the president saying.

At a recent meeting of the Republican Jewish Coalition, Mr. Trump pulled Mr. Adelson aside and asked how he thought Mr. Bolton was doing, according to a person briefed on the conversation. Mr. Adelson said that if Mr. Trump was happy, then he was happy.

But it was not clear if he was happy. When Mr. Trump sours on an adviser, he often conducts informal surveys of people in his circle asking how they think that adviser is doing — it is his way of contemplating whether he should make a change. In the case of Mr. Adelson, the president may have also been testing the reaction of Mr. Bolton’s backer, wary of offending the Republican megadonor.

One person close to Mr. Trump said the situation resembled the moment when the president turned on Rex W. Tillerson, his first secretary of state, but still took another six months or more to push him out. Others expressed doubt that Mr. Trump would get rid of Mr. Bolton before next year’s re-election campaign.

Either way, the fault lines have been drawn more sharply in recent weeks as Mr. Trump resisted sending large numbers of additional American troops to the Middle East to counter reported Iranian threats and played down signs that his diplomatic rapprochement with North Korea was turning hostile.

Mr. Trump has also grown dissatisfied with the results of another of Mr. Bolton’s top priorities: the campaign to push out President Nicolás Maduro of Venezuela. While Mr. Bolton has helped rally international condemnation of Mr. Maduro, the domestic opposition inside Venezuela has failed to turn the military against him and oust the president.

After Mr. Bolton told reporters that “there is no doubt” that North Korean missile launches violated United Nations resolutions, Mr. Trump dismissed the concern.

“North Korea fired off some small weapons, which disturbed some of my people, and others, but not me,” he wrote on Twitter on Sunday.

At a news conference the next day in Tokyo, Mr. Trump went even further by contending, inaccurately, that the missile launches did not violate United Nations resolutions. “My people think it could have been a violation, as you know,” the president said. “I view it differently. I view it as a man — perhaps he wants to get attention, and perhaps not. Who knows? It doesn’t matter.”

Later during the same appearance, Mr. Trump suggested that he did not share Mr. Bolton’s enthusiasm for trying to overthrow the government in Iran. “It has a chance to be a great country with the same leadership,” he said. “We’re not looking for regime change. I just want to make that clear. We’re looking for no nuclear weapons.”

Mr. Bolton did not address the matter afterward, and a spokesman declined to comment on Tuesday. Speculation arose when the national security adviser skipped the state dinner, although it was not clear why. But rather than fly home with the president, as an aide worried about his position might do, Mr. Bolton flew directly to the United Arab Emirates for meetings, a sign to his allies of the confidence he has in his relationship with Mr. Trump.

“Ambassador Bolton works for the president, and the president sets the policy,” said Fred Fleitz, the president of the Center for Security Policy who was Mr. Bolton’s chief of staff until last year. “Bolton has said for years: ‘Look, I work for the guy who won the election. He sets the policy.’ That’s always been his approach under any president he’s worked for.”

For his part, Mr. Bolton has privately expressed his own frustration with the president, according to several officials, viewing him as unwilling to push for more transformative changes in the Middle East. At the same time, his allies said he had been misunderstood, cast as favoring military action in Venezuela, for instance, when in fact they say he does not.

But Mr. Bolton is an inveterate disrupter, eagerly upsetting the status quo in furtherance of his policy goals. He has never seemed to worry much about offending others; he does not appear to care much about being liked.

He came into the job last year saying he hoped to emulate the process Brent Scowcroft ran under President George Bush, but he has had his own conflicts with the Pentagon and the State Department.

In reorganizing the national security apparatus, Mr. Bolton eliminated some meetings of the highest-ranking officials known as the principals’ committee, or P.C., in favor of what are called “paper P.C.s,” meaning documents that are distributed. Cabinet officers rarely complain about fewer meetings, but as one former senior administration official put it, Mr. Trump rarely if ever reads much paper of any sort.

Instead, Mr. Bolton provides briefings on issues for the president, allowing him to control the flow of information. Mr. Bolton and his allies have said he makes a point of ensuring that all points of view on major issues get aired before the president, and he does not try to block other officials from seeing Mr. Trump directly. He has breakfast once a week with Secretary of State Mike Pompeo and Acting Defense Secretary Patrick Shanahan when everyone is in town.

But he clashed with Mr. Shanahan’s predecessor, Jim Mattis. At one point, during a discussion of the cost of maintaining American troops in South Korea, Mr. Mattis forcefully told Mr. Bolton that it was not the national security adviser’s job to tell the president what to do, according to an official with direct knowledge of the meeting; it was Mr. Bolton’s job to pass on the direct recommendations of the cabinet members.

Much of the bad blood dates to last fall when the National Security Council, at Mr. Bolton’s direction, asked the Defense Department for military options to strike Iran if necessary, a request that came after militants aligned with Iran fired three mortars or rockets into an empty lot on the grounds of the United States Embassy in Baghdad.

The request alarmed Mr. Mattis and other top officials. When Mr. Bolton tried to bypass the Pentagon and go straight to the United States Central Command for military options, Mr. Mattis blocked the end run, according to a senior administration official.

Mr. Bolton was frustrated by what he saw as resistance to legitimate requests, allies said. He would be derelict in his duty not to be prepared for any contingency. Lately, Mr. Bolton has been showing up at the Pentagon more frequently to attend so-called small group meetings of top officials, which has rubbed some the wrong way.

There has also been friction between Mr. Bolton’s National Security Council and Mr. Pompeo’s State Department. While Mr. Bolton argued for canceling all waivers to buy oil from Iran, some at the State Department pushed to retain a couple. Mr. Trump sided with Mr. Bolton.

Likewise, Mr. Bolton wanted to cut off all waivers for countries participating in civil nuclear projects with Tehran, while some State Department officials worried it would aggravate the European allies. In that case, the administration compromised by revoking two waivers and preserving waivers for three sites.

Mr. Dubowitz, whose defense of democracies organization advocates more sanctions on Iran, said Mr. Bolton and Mr. Pompeo were “two men of common objectives” committed to the same strategy of maximum pressure but sometimes split over matters of sequencing and scope.

More significant, of course, is the president, who at times seems to be on both sides of the issues that consume the national security team — one day threatening to wipe Iran off the map, the next day inviting it for talks. Mr. Bolton’s admirers said any national security adviser could find himself at odds with a president who switches back and forth.

The question is whether it is a negotiating strategy or foundational uncertainty. “Who is Trump?” Mr. Dubowitz asked. “He’s not a bad cop, he’s not a good cop. He’s kind of the indecipherable, confused cop. But Bolton is always the bad cop. He doesn’t play any other role in this drama.”

Eric Schmitt, Helene Cooper and Edward Wong contributed reporting.