The ouster of national security adviser John Bolton on Tuesday removes a hawkish ideologue whose mastery of bureaucracy and disdain for the foreign policy establishment empowered President Trump to make some of his most dramatic policy shifts and undo President Barack Obama’s most prized national security achievements.

But while the two men shared a potent disdain of Obama’s foreign policy, Bolton’s appetite for military confrontation and regime change clashed repeatedly with the views of Trump, who announced his firing on Twitter.

“I informed John Bolton last night that his services are no longer needed at the White House,” Trump said. “I disagreed strongly with many of his suggestions, as did others in the Administration.”

During Bolton’s tenure, Trump withdrew from the 2015 Iran nuclear deal, moved the U.S. Embassy in Israel to Jerusalem and held a high-profile summit with Russian President Vladimir Putin in Helsinki.

Sen. James M. Inhofe (R-Okla.) reacted Sept. 10 President Trump's announcement that John Bolton was no longer his national security adviser. (The Washington Post)

When it came to unwinding previous U.S. policies Trump viewed as a nuisance, Bolton eagerly executed for the president over the objections of career diplomats and defense officials.

But the president’s desire to end America’s long-standing military conflicts and strike deals with longtime U.S. adversaries, such as Iran and North Korea, exposed sharp differences between the two men that lingered under the surface.

In June, following Trump’s decision not to order a military attack on Iran after it downed an unmanned U.S. drone, Bolton was “devastated,” said one U.S. official familiar with the matter. Bolton also opposed Trump’s desire to meet Iranian President Hassan Rouhani in an effort to strike a new deal that would limit Iran’s nuclear program and take Washington and Tehran away from the brink of a military conflict.

On North Korea, Trump came to view Bolton as a potential spoiler for a landmark nuclear deal with the isolated country and repeatedly excluded him from important meetings. During Trump’s second summit with Kim in Hanoi, Trump ordered that Bolton not be included in a dinner meeting with senior U.S. and North Korean officials. When Trump made a surprise visit to the demilitarized zone in June, Trump dispatched Bolton to Mongolia instead of having him stay in the country for the Trump-Kim meeting.

Trump repeatedly expressed frustration with Bolton and his aides over the issue Bolton was given the most control over: Venezuela. Bolton had told the president that Venezuelan President Nicolás Maduro could be quickly ousted following the U.S. imposition of economic sanctions on the country’s state oil company. But China and Russia stood by the authoritarian leader’s side, and the standoff has worsened the humanitarian situation, causing more severe food and medicine shortages.

Days before his resignation, Bolton had argued harshly against an emerging deal with the Taliban to withdraw U.S. troops in exchange for a promise that the militant group would not allow the country to become a staging ground for terrorist attacks on the United States.

Bolton had annoyed Pompeo, who oversaw the negotiations with the Taliban, less for his ideology and more for his aggressive, bureaucratic management style. As a result of these tensions, Pompeo excluded Bolton’s team from discussions on Afghanistan, Iran and North Korea. Officials complained that Bolton’s team would lose on a specific policy, such as whether to impose tougher sanctions on Iran, and then leak a distorted view of the decision to a select group of journalists.

“His team has a reputation for losing and leaking,” said one senior administration official, explaining his exclusion from key decision-making. Like others, the official spoke on the condition of anonymity to discuss internal conversations.

At the center of the tension between Trump and Bolton is a difference in ideology. Trump came to power promising an end to the United States’ “endless war,” saying that the country has wasted billions of dollars on a military presence that does more to protect wealthy U.S. allies than average American citizens.

Bolton, by contrast, harbors a view that exalts the use of American military power and favors a forceful response to traditional American adversaries such as Russia, Iran, Venezuela and North Korea. At different times, Trump sought to test diplomatic options with each country, but Bolton aggressively resisted the moves, officials said.

While Bolton tangled with the president and Cabinet officials behind the scenes, he kept a strong public show of support for the president. But the abrupt nature of his departure has raised questions about whether Bolton, a former Fox News pundit, will become a public critic of the president in his post-government life.

The two men already have found one thing to disagree on: whether Bolton resigned or was fired. In an effort to retake the narrative, Bolton tweeted Tuesday: “I offered to resign last night and President Trump said, ‘Let’s talk about it tomorrow.’ ”