Britain has reduced staff at its embassies in Iran and Iraq to a minimum level amid security concerns after the killing of a top Iranian general in a US airstrike, Sky News understands.
The withdrawal of the diplomats from both countries is a precautionary step rather than based on specific intelligence of a threat, according to diplomatic sources.
The respective ambassadors - Rob Macaire in Tehran and Stephen Hickey in Baghdad - will remain in place.
A spokesperson for the Foreign and Commonwealth Office said: "The safety and security of our staff is of paramount importance and we keep our security posture under regular review. Both our embassies in Baghdad and Tehran remain open."
Boris Johnson has been trying to distance Britain from the US as Donald Trump ramped up his rhetoric against Iran, threatening to target cultural sites.
Britain and its allies are bracing for possible retaliatory attacks in the region by Iran and its proxies in revenge for the assassination of Major General Qassem Soleimani as he was being driven out of Baghdad airport last week.
:: Listen to the Daily podcast on Apple Podcasts , Google Podcasts , Spotify , Spreaker
Iran's supreme leader vowed "severe revenge" but first declared three days of national mourning, which concluded on Monday night.
It is also understood that the Foreign Office has entered "crisis mode" in the wake of Maj Gen's Soleimani killing. This is a formal status that typically happens during an emergency situation.
In this instance, it means staff working on the Iran-US situation are operating out of a crisis centre at the Foreign Office's headquarters in Whitehall.
A special command structure has been activated and diplomats are working on shifts to be able to man the office for longer periods.
Mr Johnson went against US President Donald Trump on Monday by pointing out the international rules of war and supporting the 2015 nuclear deal with Iran - which the US pulled out of in 2018.
Mr Trump has threatened to target 52 Iranian sites, including ones of cultural importance, after Tehran threatened to retaliate over Friday's killing of Maj Gen Soleimani in a US drone strike.
Iran's foreign minister said the targeting cultural sites would constitute a war crime and likened it to Islamic State's tactics.
:: Listen to Divided States on Apple podcasts , Google Podcasts , Spotify , and Spreaker
The US president defended his threat and said if the Iranians were allowed to "torture and maim our people... use roadside bombs and blow up our people" then the US could target cultural sites.
However, Mr Johnson's spokesman said the UK had a different opinion.
"There are international conventions in place which prevent the destruction of cultural heritage," he said.
He added that the government was urgently speaking to its allies about the nuclear deal after Iran said it would abandon limitations on its uranium enrichment.
"Iran's announcement is clearly extremely concerning. It is in everyone's interests that the deal remains in place," Mr Johnson's spokesman said.
"It makes the world safer by taking the prospect of a nuclear-armed Iran firmly off the table.
"We have always said the nuclear deal is a reciprocal deal, and in light of Iran's announcement we are urgently speaking to partners about next steps."
Foreign Secretary Dominic Raab echoed the prime minister's statements later, after a meeting of senior ministers to discuss the crisis.
He said: "We have been very clear that cultural sites are protected under international law and we would expect that to be respected.
"Clearly our first priority is to make sure that UK nationals, citizens, shipping, diplomatic missions and military personnel are safe.
"We've changed our travel advice, we are going to be reinforcing in due course the Royal Navy protection for shipping in the Strait of Hormuz.
"On a diplomatic front our overwhelming message that the Prime Minister and I are conveying to our European and American counterparts, and also critically our partners in the Middle East, is the importance of deescalating the tensions and finding a diplomatic way through this crisis."
Mr Trump later tweeted: "IRAN WILL NEVER HAVE A NUCLEAR WEAPON!"
The president has threatened to impose sanctions on Iraq after its parliament voted to expel all 5,000 US troops from the country - but the prime minister's spokesman said the UK had no such plans.
Defending Mr Johnson's failure to return from his Caribbean holiday early to deal with the crisis, the spokesman said the prime minister was in contact with senior officials the entire time.
In Tehran, the supreme leader Ayatollah Ali Khamenei, who had a close relationship with the general, wept over the casket during Monday's funeral.
Iranian police said more than a million people were on the streets, many sobbing loudly, as they mourned the man who guided Iran's proxy militias abroad, ranging from Hezbollah in Lebanon to armed factions in Iraq, Syria and Yemen.
Analysis by Deborah Haynes, foreign affairs editor
Analysts warned on Monday that Britain could be deemed a soft target by Iran and its proxy forces seeking revenge for the killing of Maj Gen Soleimani.
The UK is seen as intrinsically aligned with the US, they said, noting that the Iranians might calculate that hitting a British target would send a message but might not provoke the same kind of retaliation from President Donald Trump.
While, mindful of this risk, the UK - which unlike the US has a functioning embassy in Tehran - is still keeping lines of communication open with the Iranian authorities.
In Iraq, Britain has a team of diplomats operating out of its embassy inside Baghdad's fortified green zone.
There are also some 400 British troops across Iraq. The military personnel are deployed as part of a US-led mission to counter Islamic State.
But all operations to train and support Iraqi forces fighting IS were suspended on Sunday as British and other coalition troops switched to focus on bolstering protection at the compounds where they are located from the threat of militia attack.
They had already been receiving rocket fire over the past couple of months blamed on Iraqi militiamen supported by Iran.
The death of Maj Gen Soleimani as well as senior Iraqi militia leader, Abu Mahdi al Muhandis, who was also killed in the US attack at Baghdad airport, has significantly ramped up anti-American sentiment in Iraq and across the region.
A number of rockets have since been launched at coalition bases as well as towards the US embassy inside the fortified green zone in Baghdad.
A mass protest on New Year's Eve and New Year's Day at the US embassy, which also sits inside the green zone, demonstrated the area's vulnerability.
Only authorised personnel are supposed to be granted access to the green zone and yet thousands of protesters were able to march inside and attack the American mission.
Iraq's collection of militias are sanctioned by the state and played a significant role in the fight against Islamic State, including working alongside US, British and other coalition forces.