President Donald Trump says he has sacked his national security adviser John Bolton, telling him his services are "no longer needed".
But Mr Bolton gave his own version of events, saying he had resigned.
Mr Trump and Mr Bolton, a foreign policy hawk, had significant disagreements on Iran, Afghanistan and other global challenges.
Most recently Mr Bolton opposed the president's now-scrapped plan to bring Taliban negotiators to Camp David.
Mr Trump tweeted: "I informed John Bolton last night that his services are no longer needed at the White House.
"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.
May 2019: Bolton on Brexit, Theresa May and Iran
"I thank John very much for his service. I will be naming a new National Security Advisor next week."
Mr Bolton responded afterwards, posting on Twitter: "I offered to resign last night and President Trump said, 'Let's talk about it tomorrow'."
And Fox News host Brian Kilmeade said live on air that he received a text from Mr Bolton, which said: "Let's be clear, I resigned."
Iran then claimed credit for the sacking, with one of President Hassan Rouhani's advisers saying it was the result of Iran's resistance to Mr Trump's maximum pressure campaign.
Hesameddin Ashena claimed the move was a sign of Iran's ability to manage US policies.
The departure seems to have surprised the White House press team too, who just an hour before Mr Trump's tweets said Mr Bolton would join Secretary of State Mike Pompeo and Treasury Secretary Steven Mnuchin at a briefing.
In that briefing, the pair were asked about whether the news had blind-sided them, with Mr Pompeo replying: "I'm never surprised. And I don't mean that on just this issue.
"Those of us who work with the president have a good understanding of how he is thinking.
"Our mission is not to talk about the inner workings, but the things that matter to American foreign policy."
Mr Mnuchin added: "People who knew should know."
Mr Bolton was in London less than a month ago, where he met Prime Minister Boris Johnson and said that the UK would be "first in line" for a trade deal with the US once Brexit has taken place.
Image: Mr Bolton was a controversial figure in the White House
Mr Trump once said that Mr Bolton could be "at war with the world if he could have his way". He also reportedly once said of Mr Bolton: "John has never seen a war he doesn't like."
Reacting to the news, Anthony Scaramucci, Mr Trump's one-time communications director, tweeted: "No one survives @realDonaldTrump its b/c he hates himself.
"If you are still in the @WhiteHouse he is coming for you. Yes it is a horror movie."
There has been talk of conflict between Mr Bolton and Mr Pompeo, who are said to not be speaking to one another.
In the press conference, Mr Pompeo said he and Mr Bolton had different views on how to proceed in diplomacy, but that disagreements were true in many of his daily interactions.
He said Mr Trump was "entitled to the staff he wants".
Mr Bolton had been a controversial figure in the White House and his appointment caused some alarm.
His foreign policy views did not seem to fit with Mr Trump's "America First" approach.
Mr Bolton was opposed to Mr Trump's now cancelled meeting with Taliban leaders, which had been planned to take place on Sunday at the president's Camp David country retreat.
Mr Trump has described reports he overruled vice-president Mike Pence and other advisers on the meeting as "false", adding: "I always think it is good to meet and talk, but in this case I decided not to."
Mr Bolton also disagreed with Mr Trump's decision to hold back on military strikes against Iran, and had advocated caution on America's approach towards North Korea.
He was against the withdrawal of troops from Syria and masterminded a quiet campaign inside the White House to convince Mr Trump to keep forces in the Middle East country to counter Islamic State and Iranian influence.
Mr Bolton had become a more isolated figure in recent times.
Image: Mr Trump had disagreed with Mr Bolton on a number of issues
His sacking is less civil than prior departures from the White House, without the usual platitudes and tributes.
And it comes despite some previous praise of Mr Bolton from Mr Trump, who tweeted about him as far back as 2014 and previously told allies he is "a killer" on TV.
Mr Bolton is the third national security adviser in the Trump administration, talking over in April 2018 after the departure of General HR McMaster.
He is the longest-serving adviser so far, making it to 520 days, with Gen. McMaster lasting 412 days, and Michael Flynn just 24 days.
He also served in George W Bush's administration, as the US ambassador to the UN, and was a strong supporter of the 2003 Iraq war.
Mr Bolton even briefly considered running for president in 2016.
Did he jump or was he pushed?
Analysis by Amanda Walker, US correspondent
Donald Trump was reportedly hesitant about hiring John Bolton because of his moustache.
But facial hair was the least of their differences.
The outgoing National Security Adviser has always been a known quantity: he's a flag bearer for American hard power - openly hawkish and deeply suspicious of diplomatic moves on rogue states.
Businessman Trump came into the White House on an anti-intervention promise - as the self-professed deal maker in chief - a master negotiator who could bring previously unattainable countries to the negotiating table. Their strategies could not be more different.
Mr Trump loves the optics of sitting down with the likes of North Korean leader Kim Jong Un - the historic headlines of achieving face to face moments that evaded his predecessors - even if those meetings yield very little after the fact.
Mr Bolton shunned such moments and actively, sometimes publicly, derided them. Mr Trump's nationalist platform is based on scepticism of the sort of foreign interventions that Mr Bolton has championed.
The search is now on for a replacement who echoes Mr Trump's anti-interventionist leanings. Whoever he or she is will be his fourth National Security Adviser - a hugely important role that surely does not benefit from such frequent turnover.
There's a lot at stake with big foreign policy challenges in Iran, Afghanistan and North Korea. All of which Mr Bolton clashed with Mr Trump over.
This is one of dozens of high-profile White House departures. Usually there's an attempt to make it appear amicable - to quash reports of a chaotic administration.
But Mr Trump appears to be on a collision course at the moment with little care for 'optics'. He wants and openly seeks 'yes' men who will loyally do his bidding without question.
There are reports that Mr Bolton was lined up to go on Sunday talk shows and defend Mr Trump, but he backed out, unwilling to back his boss on issues like Russia and Afghanistan.
If true, his fate was then sealed.
Mr Bolton isn't going down without a fight, insisting he walked and wasn't pushed.
Whatever he chooses to say publicly in the aftermath of his exit will only compound the view of an administration run by the whim of one person and one person alone.