Protesters in the Iranian capital, Tehran, have broken into the UK embassy compound during a demonstration against sanctions imposed by Britain.
Militant students are reported to have ransacked offices, burned the British flag and smashed embassy windows.
The move comes after Iran resolved to reduce ties following the UK's decision to impose further sanctions on it.
Iran expressed "regret" over the attack on the embassy. The Foreign Office has summoned an Iranian diplomat in London.
British Prime Minister David Cameron said: "The attack on the British embassy in Tehran today was outrageous and indefensible."
He said those responsible for the attack must be prosecuted.
"I spoke to our Ambassador this afternoon and was reassured that everyone has been accounted for," Mr Cameron added.
UK Foreign Secretary Hague said the Iranian charge d'affaires had been summoned, adding: "Clearly there will be other, further, and serious consequences."
The Foreign Office urged Britons in Iran to "stay indoors, keep a low profile and await further advice".
The Iranian Foreign Ministry expressed "regret for certain unacceptable behaviour by a small number of protesters in spite of efforts by the police".
"The relevant authorities have been asked to take the necessary measures and look into this issue immediately," it said.
The students clashed with riot police and chanted "the embassy of Britain should be taken over" and "death to England".
Students were said to have ransacked offices inside the building, and one protester was reported to be waving a framed picture of Queen Elizabeth II.
Iran's semi-official Mehr news agency said embassy documents had been set alight. Staff fled by the back door, the agency added.
Pictures showed a car inside the compound on fire while several hundred other demonstrators were gathered outside the embassy's walls.
A separate group of protesters also broke into another British embassy compound in the north of the city, the UK Foreign Office confirmed. It was not clear how much damage was done there.
After about two hours, police were back in control of the main embassy building. Live TV footage showed riot police removing protesters.
Security forces fired tear gas, the semi-official Fars news agency reported. It said some protesters and police had been injured in the clash.
Eventually, both compounds were cleared, Iranian media reported.
There was strong international reaction to Tuesday's events.
The 15-nation UN Security Council - which has passed four rounds of sanctions against Iran over its nuclear programme - condemned the attack "in the strongest terms".
US President Barack Obama said he was "deeply disturbed" by events in Tehran.
"I strongly urge the Iranian government to hold those responsible to task," he added.
Germany also summoned its Iranian ambassador over the storming of the British embassy - in which a German school was also damaged.
Foreign Minister Guido Westerwelle called it "a violation of international law".
French Foreign Minister Alain Juppe said "the Iranian regime has shown what little consideration it has for international law".
Russia said the attack was "unacceptable".
Last week the US, UK and Canada announced new measures targeting Iran over its controversial nuclear plans.
For its part, the UK Treasury imposed sanctions on Iranian banks, accusing them of facilitating the country's nuclear programme
That decision followed a report from the International Atomic Energy Agency (IAEA) that suggested Iran was working towards acquiring a nuclear weapon.
It said Iran had carried out tests "relevant to the development of a nuclear device".
Iran insists its nuclear programme is for peaceful purposes only.
On Sunday, Iran's parliament voted by a large majority to downgrade diplomatic relations with the UK in response to the British action.
Iranian radio reported that some MPs had chanted "Death to Britain" during the vote, which was approved by 87% of MPs.