WASHINGTON — President Trump on Tuesday pushed out John R. Bolton, his third national security adviser, amid fundamental disputes over how to handle major foreign policy challenges like Iran, North Korea and most recently Afghanistan.
The departure ended a 17-month partnership that had grown so tense that the two men even disagreed over how they parted ways, as Mr. Trump announced on Twitter that he had fired the adviser only to be rebutted by Mr. Bolton, who insisted he had resigned of his own accord.
A longtime Republican hawk known for a combative style, Mr. Bolton spent much of his tenure trying to restrain the president from making what he considered unwise agreements with America’s enemies. Mr. Trump bristled at what he viewed as Mr. Bolton’s militant approach, to the point that he made barbed jokes in meetings about his adviser’s desire to get the United States into more wars.
Their differences came to a climax in recent days as Mr. Bolton waged a last-minute campaign to stop the president from signing a peace agreement at Camp David with leaders of the radical Taliban group. He won the policy battle as Mr. Trump scrapped the deal but lost the larger war when the president grew angry about the way the matter played out.
Mr. Trump and his aides privately blamed the national security adviser for news reports describing Mr. Bolton’s opposition to the deal. Vice President Mike Pence and his camp likewise grew angry at reports suggesting he had agreed with Mr. Bolton, seeing them as an effort to bolster the adviser’s position.
“I informed John Bolton last night that his services are no longer needed at the White House,” the president tweeted. “I disagreed strongly with many of his suggestions, as did others in the Administration, and therefore I asked John for his resignation, which was given to me this morning. I thank John very much for his service.”
Mr. Bolton disputed the president’s version of events in his own tweet 12 minutes later. “I offered to resign last night and President Trump said, ‘Let’s talk about it tomorrow,’” Mr. Bolton wrote, without elaborating.
Responding to a question from The New York Times via text, Mr. Bolton said his resignation was his own initiative, not the president’s. “Offered last night without his asking,” he wrote. “Slept on it and gave it to him this morning.”
Mr. Trump said he would appoint a replacement “next week,” setting off a process that should offer clues to where he wants to take his foreign policy. In the meantime, the White House said Charles M. Kupperman, the deputy national security adviser, would serve in an acting capacity. No other president has had four national security advisers in his first three years in office.
While it was clear for months that Mr. Bolton was on thin ice, the end came with typically brutal suddenness. On Tuesday morning, he led a meeting of the national security principals in the Situation Room, with no sign that anything was about to break.
At 11 a.m., the White House even scheduled a 1:30 p.m. news briefing where Mr. Bolton would talk about terrorism alongside Secretary of State Mike Pompeo and Treasury Secretary Steven Mnuchin. But then came Mr. Trump’s tweet two minutes before noon, and Mr. Bolton left the White House.
The briefing went forward without him, and Mr. Pompeo, who has feuded with Mr. Bolton for months, shed no tears about the president’s decision. “He should have people he trusts and values, and whose efforts and judgments benefit him in delivering American foreign policy,” Mr. Pompeo told reporters.
The secretary also made no effort to hide his rivalry with Mr. Bolton. “There were definitely places that Ambassador Bolton and I had different views about how we should proceed,” he said. Asked if he was blindsided by the decision, Mr. Pompeo said, “I’m never surprised,” as he and Mr. Mnuchin grinned broadly.
Mr. Pompeo and Mr. Bolton generally shared a conservative policy outlook, but the secretary of state has proved more adept at managing the president and subordinating his views to Mr. Trump’s, while Mr. Bolton kept pushing his beliefs even after they were rejected.
Mr. Pompeo did not see Mr. Bolton as a team player, but as someone who undermined the president’s policies. Mr. Bolton saw Mr. Pompeo as a politician more interested in currying Mr. Trump’s favor to have his support in a future run for Senate.
Mr. Bolton’s adversaries inside the administration have been after him for weeks, spreading stories about how the national security adviser had been excluded from meetings and was on the outs with the president.
When Mr. Bolton backed out of appearing on two Sunday talk shows during the Group of 7 summit last month, his internal critics said it was because he refused to defend the president’s policies on Russia. Mr. Bolton denied that, saying he did not go on the shows because the main topic was the trade war with China, which is not his area of specialty.
Since President Trump’s inauguration, White House staffers and cabinet officials have left in firings and resignations, one after the other.
Mr. Bolton, the hard-liner, saw his job as keeping Mr. Trump from going soft in what he saw as fuzzy-headed diplomacy. “While John Bolton was national security adviser for the last 17 months, there have been no bad deals,” a person close to Mr. Bolton said minutes after the president’s announcement on Tuesday, reflecting the ousted adviser’s view.
To Mr. Bolton’s aggravation, the president has continued to court Kim Jong-un, the repressive leader of North Korea, despite Mr. Kim’s refusal to surrender his nuclear program and despite repeated short-range missile tests by the North that have rattled its neighbors.
In recent days, Mr. Trump has also expressed a willingness to meet with President Hassan Rouhani of Iran under the right circumstances, and even to extend short-term financing to Tehran. Mr. Pompeo confirmed on Tuesday that it was possible such a meeting could take place this month on the sidelines of the United Nations General Assembly session in New York.
The tension between the men was aggravated in recent months by the president’s decisions to call off a planned airstrike on Iran in retaliation for the downing of an American surveillance drone and to meet with Mr. Kim at the Demilitarized Zone and cross over into North Korea.
Mr. Bolton favored the strike on Iran and publicly criticized recent North Korean missile tests that Mr. Trump brushed off. Mr. Trump disavowed regime change in Iran, a long-held goal of Mr. Bolton’s. After the president arranged the DMZ meeting with Mr. Kim via a last-minute tweet, Mr. Bolton did not accompany him and instead proceeded on a previously scheduled trip to Mongolia.
The day after the DMZ meeting, Mr. Bolton pushed an internal policy debate into the open by disputing a Times story reporting that some administration officials were considering an agreement with North Korea for a nuclear freeze as an intermediate step toward full disarmament.
Mr. Bolton, on Twitter, accused someone of trying to “box in the President” and said “there should be consequences.” It soon became clear those officials were Mr. Pompeo and his special envoy, Stephen E. Biegun, making Mr. Bolton’s tweet a veiled attack on them.
The same day, Mr. Bolton’s aides obtained a copy of notes taken by State Department reporters during an off-the-record briefing with Mr. Biegun discussing the nuclear freeze. Mr. Bolton tried to use those notes as a cudgel in the internal policy battle, administration officials said. Details of Mr. Biegun’s meeting were leaked to the news outlet Axios.
Mr. Bolton’s departure caught allies and adversaries off-guard. Senator Mitt Romney, Republican of Utah, called the news “an extraordinary loss for our nation and the White House.”
“John Bolton is a brilliant man with decades of experience in foreign policy,” he said. “His point of view was not always the same as everybody else in the room. That’s why you wanted him there. The fact that he was a contrarian from time to time was an asset, not a liability.”
But Republicans like Senator Rand Paul of Kentucky who have tried to push Mr. Trump away from foreign intervention were openly gleeful.
“The threat of war worldwide goes down exponentially with John Bolton out of the White House,” Mr. Paul told reporters. “I think his advocacy for regime change around the world is a naïve worldview, and I think that the world will be a much better place with new advisers to the president.”
Among others pleased to be rid of Mr. Bolton were Iran’s leaders, who viewed him as an enemy of peace. Hesameddin Ashena, Mr. Rouhani’s top political adviser, tweeted that Mr. Bolton getting sidelined was “a definitive sign that Washington’s maximum pressure on Iran has failed” and that “Iran’s blockade will end.”
A former under secretary of state and ambassador to the United Nations under President George W. Bush, Mr. Bolton, 70, known for his trademark bushy mustache, was tapped as national security adviser in March 2018 after impressing Mr. Trump with his outspoken performances on Fox News.
Mr. Bolton followed two military officers who held the post before him: Michael T. Flynn, a retired lieutenant general who stepped down after 24 days and later pleaded guilty to lying to the F.B.I.; and his successor, Lt. Gen. H. R. McMaster, who never forged a strong connection with the president and was forced out.
Long before Mr. Trump popularized his “America First” slogan, Mr. Bolton termed himself an “Americanist” who prioritized a cold-eyed view of national interests and sovereignty over what they both saw as a starry-eyed fixation on democracy promotion and human rights. They shared a deep skepticism of globalism and multilateralism, a commonality that empowered Mr. Bolton to use his time in the White House to orchestrate the withdrawal of the United States from arms control treaties and other international agreements.
But if Mr. Trump’s original national security team was seen as restraining a mercurial new commander in chief, the president found himself sometimes restraining Mr. Bolton. Behind the scenes, he joked about Mr. Bolton’s penchant for confrontation. “If it was up to John, we’d be in four wars now,” one senior official recalled the president saying.
Mr. Trump also grew disenchanted with Mr. Bolton over the failed effort to push out President Nicolás Maduro of Venezuela. Rather than the easy victory he was led to anticipate, Mr. Trump has found himself bogged down in a conflict over which he has less influence than he had assumed.
Russia was another flash point for the two. While Mr. Trump seeks to woo President Vladimir V. Putin, Mr. Bolton considers Moscow a hostile player. After Mr. Trump last month suggested inviting Russia back into the Group of 7 despite its annexation of Crimea, Mr. Bolton traveled to Ukraine to reassure its leaders of American support against Russian aggression.