Britain would take the 'irresponsible action' of the attack on the embassy in Tehran 'very seriously', said foreign secretary William Hague Reuters

Britain has threatened "serious consequences" for Iran after protesters stormed the British embassy in Tehran, ransacking offices and diplomatic residences and triggering one of the worst crises in bilateral relations since the Islamic revolution 32 years ago.

A mob including members of the paramilitary basij brigades, under the control of Iran's Revolutionary Guards, surged through lines of riot police and broke into the embassy and a separate residential compound, the Qolhak Gardens, in northern Tehran, chanting "Death to England" in scenes reminiscent of the seizure of the US embassy in 1979.

British diplomatic staff ran for safety and locked themselves in their offices and homes, with one group of about a dozen pinned down by the crowd while others were jostled, although there were no serious injuries. The crowd ripped the gildedUK crest off the embassy, pulled down the union flag and replaced it with the Iranian one, and threw satellite dishes off the roofs of embassy buildings. They also smashed windows and scattered thousands of papers in the street in front of the embassy, where British, US and Israeli flags were set alight.

At the Qolhak compound, a crowd roamed the wooded site where embassy staff live in flats and bungalows set among the trees, complicating the Foreign Office's efforts to confirm their safety.

Police only appeared to have regained control of both compounds by late evening, when the Tehran police chief, Hossein Sajedinia, announced that they had been emptied of protesters, and that some would be prosecuted. Iran's foreign ministry issued a statement expressing regret over the "unacceptable behaviour by [a] few demonstrators" and promising an investigation.

In London, David Cameron chaired a meeting of the cabinet's emergency committee, COBR, and the foreign secretary, William Hague, threatened "serious consequences" for the embassy invasion, which he described as "a very serious failure by the Iranian government". He is due to make a statement to parliament on Wednesday. A Foreign Office source said Britain's response would be "clear and robust".

Cameron said on Tuesday: "Those responsible for this criminal attack must be prosecuted. 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."

Hague said: "The United Kingdom takes this irresponsible action extremely seriously. It amounts to a grave breach of the Vienna convention which requires the protection of diplomats and diplomatic premises under all circumstances. We hold the Iranian government responsible for its failure to take adequate measures to protect our embassy, as it is required to do."

He confirmed that by 6pm, all the embassy's British staff had been accounted for, and most local employees had been warned not to come in on Tuesday in anticipation of trouble. But he added: "We are urgently establishing the whereabouts of our locally engaged security staff to ensure their wellbeing." He advised British nationals to "stay indoors, keep a low profile and await further advice".

The US and France also condemned the embassy raid, while the UN security council passed a resolution condemning the incident.

"The members of the security council condemned in the strongest terms the attacks against the United Kingdom's embassy in Tehran, Iran, which resulted in intrusions into the diplomatic and consular premises, causing serious damage," the Portuguese UN ambassador, José Filipe Moraes Cabral, said.

"Expressing their deep concern at such attacks, the members of the security council called on the Iranian authorities to protect diplomatic and consular property and personnel and to respect fully their international obligations," the UN statement said.

A British official added that the priority was assessing the scale of the damage and ensuring the security of all staff before announcing a response. He said there had been no significant injuries.

"There was some pushing and shoving but nothing too serious," the official said. "Some staff had their freedom of movement restricted. At one point, there was a group of about a dozen in one location, with a few Iranian police guarding the door and demonstrators roaming around outside. So a hairy and scary situation but nothing that could be described as a hostage situation."

The storming of the British embassy was the latest, and most violent, blow struck in a long-running battle of wits over Iran's nuclear programme. Diplomats had been expecting a major protest in Tehran on Tuesday to mark the first anniversary of the assassination of a senior Iranian nuclear scientist, Majid Shahriari, one of three killed over the past two years in the streets of the capital. The protesters carried picture of the dead scientists, who have been made martyrs to Iran's nuclear cause and symbols of the state's determination to press on with its programme in defiance of UN security council resolutions calling for a suspension of uranium enrichment.

It only became clear when the crowds began to gather outside the embassy on Ferdowsi Avenue and at Qolhak gardens on Tuesday morning that Britain would be the sole target of the protests, but it was not altogether surprising. Relations between Iran and the UK have almost always been tense since the Islamic revolution of 1979, and full ambassadorial ties have been the exception rather than the norm. In 1986 members of the Revolutionary Guards beat up the British charge d'affaires and 2007 saw the Iranian detention of 15 British sailors and marines in disputed waters along the Iraqi border. They were released after nearly two weeks in captivity.

Relations continued to deteriorate after the 2009 presidential election, when the regime blamed Britain for supporting the opposition Green movement. Iranian staff at the embassy were detained and ordered to resign their positions. Ordinary Iranians were warned not to have any contact with British diplomats. The Tehran municipal authorities meanwhile reinvigorated a long-running campaign to wrest back control of the 50-acre Qolhak Gardens, given to the British diplomatic mission by the Persian monarchy in the 19th century.

The latest crisis began with the publication this month of a report by the International Atomic Energy Agency, citing "credible" evidence that Iranian scientists had experimented with a nuclear warhead design and could be continuing to do so. The UK was the first to respond with punitive measures, cutting all ties to the Iranian banking system and parliament, the Majlis, which retaliated on Sunday by calling for the expulsion of Britain's ambassador, Dominick Chilcott, and the permanent downgrading of bilateral relations.

Richard Dalton, who served as ambassador to Tehran from 2002 to 2006, said the bilateral relationship had always been troubled, but Tuesday's riot was the first actual incursion into the embassy.

"This takes us to a bad feeling in bilateral relations we have not seen for a couple of decades. In my time, there were frequent demonstrations and we were always concerned that this would happen," he said. "The plan if it did happen was to sit tight and call on the [Iranian] authorities to fulfil their legal obligation to protect the embassy, which is an obligation the Iranians do recognise.

"The positive part of this is that the Iranians seem to have done the right thing in the end. The negative side, which is very serious and worthy of strong complaint, is that they didn't seem to have an adequate police presence to stop it happening in the first place."

A British official said that the police had ample warning that there could be violent protests directed at the embassy.

"It was transparently clear that some hardline pro-regime elements were putting it about on the internet and on social media: let's go and trash the Brits. So there is no doubt that if they wanted to stop this from happening they could have. When it came to opposition demonstrators they didn't have the same difficulties," the official said.

Diplomats and observers who reviewed video footage of the incident said it was clear from the clothing, placards and behaviour of some of the protesters that a significant number were basiji, who were the regime's shock troops in crushing street protests after the 2009 election.

Some of the placards bore the picture of Qassem Suleimani, the head of the Quds Force, the Revolutionary Guards' external wing, which has been active in Iraq and Syria. The US blamed him and his force last month for an alleged plot to kill the Saudi ambassador to the US in a Washington restaurant where he would be dining.

Suleimani, seen as a radical and growing force in the constant jostling for power in Tehran, once wrote to General David Petraeus, telling the then US commander in Iraq that it was he, Suleimani, who controlled Iranian foreign policy in the region.

The storming of the embassy came at a time when conservatives in the parliament, judiciary and security forces are resisting efforts by President Mahmoud Ahmadinejad to defuse the rising tensions in Iran's relations with the rest of the world, amid ever-tightening sanctions, growing diplomatic isolation and chronic economic problems. Some diplomats said Monday's events were as much a measure of the internal turmoil inside the Tehran regime as the bitterness of its relations with the west.