Tehran, Iran (CNN) -- Britain condemned Iran for allowing protesters to storm its embassy and a separate diplomatic compound in Tehran on Tuesday, warning there will be "serious consequences" as a result.





The incursion happened after about 1,000 people gathered near the embassy to demand that the British ambassador be sent home immediately. The rally began quietly, but some participants then stormed the building, breaking down the door, throwing around papers and replacing the British flag with an Iranian one.





A CNN producer saw protesters -- identified as students in state news outlets -- throwing stones at the embassy's windows. They scuffled with and overwhelmed police at the embassy gate and around the compound.





British Prime Minister David Cameron described the incursion as "outrageous and indefensible" and demanded that Iran immediately ensure the safety of all British Embassy personnel.





Iranian security forces are responsible for guarding the embassy under international law, he said.





"The failure of the Iranian government to defend British staff and property was a disgrace," he said. He called on Iran's government to guarantee the safety of embassy staff, return property seized in the fracas and prosecute those responsible.





"The Iranian government must recognize that there will be serious consequences for failing to protect our staff," Cameron said. "We will consider what these measures should be in the coming days."





By Tuesday evening, the protesters had been cleared from both sites by police, the semi-official Fars news agency reported. Police arrested 12 students as they left the diplomatic compound, called Gholhak Garden, the news agency said.





British diplomats and their families and Iranian families who work for the British Embassy live at Gholak Garden, in northern Tehran. Foreign Secretary William Hague said the "irresponsible action" had put the safety of diplomats and their families at risk and caused extensive damage to embassy property.





He had spoken to his Iranian counterpart, Ali Akbar Salehi, Tuesday to "protest in the strongest terms," he said.





"While he said that he was sorry for what had happened and that action would be taken in response, this remains a very serious failure by the Iranian government," Hague said. "Clearly there will be other, further, and serious consequences."





Hague will address the British Parliament Wednesday, he said.





Iran's Foreign Ministry expressed its regret for the student protest, "which turned into an out of control demonstration," in a statement on its website. The ministry said it would "take action through legal channels" against those who stormed the embassy building.





The Foreign Office said it had asked the Iranian charge d'affaires in London "to urge the Iranian authorities to act with utmost urgency to ensure the situation is brought under control."





It is now advising British nationals in Iran "to stay indoors, keep a low profile and await further advice."





"There has been an incursion by a significant number of demonstrators into our embassy premises, including vandalism to our property," the Foreign Office said earlier. "We are outraged by this. It is utterly unacceptable and we condemn it."





The U.N. Security Council condemned the incursion "in the strongest terms" in New York. Its statement called on Iran "to protect diplomatic and consular property and personnel, and to respect fully their international obligations in this regard."





The White House condemned the incident and "urged Iran to fully respect its international obligations, to condemn the incident, to prosecute the offenders, and to ensure that no further such incidents take place either at the British Embassy or any other mission in Iran."





"Our State Department is in close contact with the British government and we stand ready to support our allies at this difficult time," the White House said.





The Russian Foreign Ministry also condemned the protesters' actions.





"We are expressing our support for the British diplomats. We hope that the Iranian authorities will take necessary measures to immediately restore order, investigate the incident and prevent a repeat of such incidents," the ministry said in a written statement.





The demonstration followed a
Is the Iran Foreign Ministry sorry for the event? What country were the students from? Which embassy were the students at? Who has left the British Embassy compound? who said is was outrageous and indefensible
he said that he was Iran Britain 12 students British Prime Minister David Cameron
question: Is the Iran Foreign Ministry sorry for the event?, answer: he said that he was | question: What country were the students from?, answer: Iran | question: Which embassy were the students at?, answer: Britain | question: Who has left the British Embassy compound?, answer: 12 students | question: who said is was outrageous and indefensible, answer: British Prime Minister David Cameron