Britain has expressed outrage over an attack on its embassy in Tehran by protesters and given warning about "serious consequences".
The Iranians stormed two British diplomatic compounds on Tuesday, smashing windows, torching a car and burning the British flag in apparent protest against new sanctions imposed by the UK.
David Cameron, the British prime minister, chaired a meeting of the government crisis committee to discuss the attacks which he said were "outrageous and indefensible."
"The failure of the Iranian government to defend British staff and property was a disgrace," he said in a statement.
"The Iranian government must recognise that there will be serious consequences for failing to protect our staff. We will consider what these measures should be in the coming days."
Britain said on Wednesday it had withdrawn some diplomatic staff from Tehran after protesters stormed and ransacked its embassy in the Iranian capital.
"The Prime Minister and Foreign Secretary have made clear that ensuring the safety of our staff and their families is our
immediate priority," the Foreign Office said in a statement.
"In light of yesterday's events, and to ensure their ongoing safety, some staff are leaving Tehran."
The UN Security Council has condemned the attacks "in the strongest terms" while Barack Obama, the US president, has called on Iran to hold to account those responsible.
The attack comes at a time of rising diplomatic tension between Iran and Western nations that last week imposed fresh sanctions over the Islamic republic's nuclear programme, which they believe is aimed at achieving the capability of making an atomic bomb.
Iran, the world's fifth biggest oil exporter, says it only wants nuclear plants to generate electricity.
In Tuesday's incident, several dozen protesters broke away from a crowd of a few hundred outside the main British embassy compound in the business district of Tehran, scaled the gates, broke the locks and went inside.
They pulled down the British flag, burned it and put up the Iranian flag, according to images shown by Iranian news agencies. Inside the compound, the demonstrators smashed windows of office and residential quarters and set a car ablaze, news pictures showed.
One took a framed picture of Queen Elizabeth, state TV showed. Others carried the royal crest out through the embassy gate as police stood by, pictures carried by the semi-official Fars news agency showed.
The agency referred to the protesters as students who were chanting "Death to America", "Death to England" and "Death to Israel" among other slogans.
All embassy personnel were accounted for, a British diplomat told the Reuters news agency in Washington, saying the UK did not believe that any sensitive materials had been seized.
Demonstrators waved flags symbolising martyrdom and held aloft portraits of Iran's supreme leader, Ayatollah Ali Khamenei, who has the final say on matters of state in Iran.
Another group of protesters broke into a second British compound at Qolhak in north Tehran, the IRNA state news agency said.
Once the embassy's summer quarters, the tree-lined compound is now used to house diplomatic staff.
Staff briefly held
An Iranian report said six British embassy staff had been briefly held by the protesters.
"Police freed the six people working for the British embassy in Qolhak garden," Iran's Fars news agency said.
A German school next to the Qolhak compound was also damaged, the German government said.
Police cleared the demonstrators in front of the main embassy compound, but later clashed with protesters and fired tear gas to try to disperse them, Fars said.
Protesters nevertheless entered the compound a second time, before once again leaving, it said.
Police arrested 12 people who had entered the north Tehran compound, Fars said, quoting a police chief as saying they would be handed over to the judiciary.
There have been regular protests outside the British embassy over the years since the 1979 Islamic revolution that toppled the shah, but never have any been so violent.
Al Jazeera's Dorsa Jabbari said from Tehran that the police and various ministries had prior knowledge of the protest, which was organised by the student arm of the Basij armed group.
"Any such action of this could scale can never be independent in the Islamic republic," she said. "These gatherings are always approved by higher officials."
An Iranian official told Reuters the attack was not planned by the government. "It was not an organised measure. The establishment had no role in it. It was not planned," said the official, who declined
to be identified.
Iran's foreign ministry said it regretted the attacks and was committed to ensuring the safety of diplomats.
The demonstrations appeared to be a bid by conservatives who control parliament to press home their demand, passed in parliament last week and quickly endorsed by the Guardian Council on Tuesday, for the government to expel the British ambassador in retaliation for the sanctions.
A politician had cautioned on Sunday that angry Iranians could storm the British embassy.
"Parliament officially notified the president over a bill regarding degrading the ties with Britain, obliging the government to implement it within five days," Fars quoted Ali Larijani, the parliament speaker, as saying.
The government of Mahmoud Ahmadinejad has shown no willingness to compromise on its refusal to halt its nuclear work, but has sought to keep channels of negotiation open in an effort to limit the worst effects of sanctions.
Source: Al Jazeera and agencies