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 vote Sunday by the Iranian Parliament to expel the ambassador and reduce diplomatic relations with the United Kingdom in retaliation for newly imposed Western sanctions, according to Iran's official Islamic Republic News Agency, or IRNA.
Alaedi Boroujerd, the member of Parliament who introduced the measure, was quoted by IRNA as saying the students' protest was "the crystallization of their pure inner feelings."
"As declared many times before, because of its behavior, Britain is hated by the Iranian nation throughout history," he said, according to IRNA.
However, he also was quoted as saying Iran respects all international rules and the Vienna Convention, and no country or their embassies should have any further worries, including the British.
The British Foreign Office called the Iranian Parliament's vote Sunday "regrettable."
"This unwarranted move will do nothing to help the regime address their growing isolation or international concerns about their nuclear program and human rights record," the office said in a written statement. "If the Iranian government acts on this, we will respond robustly in consultation with our international partners."
Britain cut all financial ties with Iran last week over concerns about Iran's nuclear program, the first time it has cut an entire country's banking sector off from British finance, the British Treasury announced.
All British credit and financial institutions were ordered to end their business relationships and transactions with all Iranian banks, their branches and subsidiaries by Monday.
The move came after an International Atomic Energy Agency report highlighted new concerns about "the possible military dimensions of Iran's nuclear program," the Treasury statement said Monday.
"The IAEA's report last week provided further credible and detailed evidence about the possible military dimensions of the Iranian nuclear program," Hague said in a statement last Monday. "Today we have responded resolutely by introducing a set of new sanctions that prohibit all business with Iranian banks."
Iran insists its nuclear program is peaceful and has called the U.N. watchdog's report "unbalanced" and "politically motivated."
The British sanctions underline "the severity of the government's concerns about Iran's activities," Britain's chancellor of the exchequer said.
The chancellor's statement said other "partner countries" will make similar announcements about banking sanctions against Iran.
Iran's proposal mandates the Foreign Ministry to adopt similar positions against any other countries that impose the same policies as Britain, IRNA reported.
CNN's Antonia Mortensen, Claudia Rebaza, Shirzad Bozorgmehr and Mitra Mobasherat contributed to this report.