Iranian protesters briefly took six British embassy staff hostage on Tuesday when they stormed two diplomatic compounds in Tehran, smashing windows, hurling petrol bombs and burning the British flag in a protest against sanctions imposed by Britain.

Britain said it was outraged by the attacks on its embassy compounds, but had no immediate comment on the seizure of its staff who, Iran's semi-official Fars news agency said, were freed by police from a leafy residential complex in north Tehran.

The attacks come at a time of rising diplomatic tension between Iran and Western nations who last week imposed fresh sanctions over Tehran'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.

The embassy storming is also a clear sign of deepening political infighting within Iran's ruling hardline elites with the conservative-led parliament attempting to force the hand of President Mahmoud Ahmadinejad and expel the British ambassador.

Several dozen protesters broke away from a crowd of a few hundred outside the main embassy compound in downtown Tehran, scaled the gates, broke the locks and went inside.

Protesters pulled down the British flag, burnt it, and put up the Iranian flag, Iranian news agencies and news pictures showed. Inside, the demonstrators threw stones and petrol bombs. One waved 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 Fars news agency showed. Demonstrators waved flags symbolising martyrdom and held portraits of Supreme Leader Ayatollah Ali Khamenei.

Another group of protesters broke into a second British Embassy compound at Qolhak in north Tehran, the IRNA state news agency said. Once the embassy's summer quarters, the sprawling, tree-lined compound is now used to house diplomatic staff.

Six embassy staff were taken hostage there, but were later freed by police, Fars news agency reported.

Police freed the six people working for the British embassy in Qolhak garden, Fars said.

A German school next to the Qolhak compound was also damaged, the German government said.

Police appeared to have cleared the demonstrators in front of the main downtown embassy compound, but later clashed with hardline protesters and fired tear gas to attempt to disperse them, Fars said.

Protesters nevertheless again entered the compound, Fars said.

The British Foreign Office said it was outraged.

There has been an incursion by a significant number of demonstrators into our Embassy premises, including vandalism to our property, the Foreign Office said in a statement. This is a fluid situation and details are still emerging. We are outraged by this. It is utterly unacceptable and we condemn it.

Britain said the Iranian government had a duty under international law to protect diplomats and urged Iranian authorities to act with utmost urgency to bring the situation under control.

IRAN PARLIAMENT WANTS UK AMBASSADOR OUT

There have been regular protests outside the British embassy over the years since the 1979 Islamic revolution that toppled the U.S.-backed shah, but never have any been so violent.

The attacks and hostage-taking was reminiscent of the 1979 takeover of the U.S. embassy in Tehran carried out by radical students who held 52 Americans hostage for 444 days. The United States and Iran have cut diplomatic ties ever since.

An Iranian official told Reuters the storming of two British compounds on Tuesday 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 attacks followed the rapid approval by Iran's Guardian Council of a parliamentary bill compelling the government to expel the British ambassador in retaliation for the sanctions. A lawmaker had also warned on Sunday that angry Iranians could storm the British embassy as they did the U.S. mission in 1979.

Ahmadinejad's government, often at odds with conservatives who control the parliament, has five days to expel Britain's ambassador, the speaker of parliament said.

Parliament officially notified the president over a bill regarding degrading the ties with Britain, obliging the government to implement it within five days, Fars news agency quoted speaker Ali Larijani as saying.

Radicals in Iran and in the West are always in favour of crisis ... Such radical hardliners in Iran will use the crisis to unite people and also to blame the crisis for the fading economy, said political analyst Hasan Sedghi.

The incident followed Britain's imposition of new sanctions on the Islamic state last week over its nuclear programme.

London banned all British financial institutions from doing business with their Iranian counterparts, including the Central Bank of Iran, as part of a new wave of sanctions by Western countries.

In London, Foreign Secretary William Hague said Britain expected other countries to follow its lead in imposing financial sanctions on Iran and will take robust action if Tehran reduces their diplomatic relations.

Hague was speaking in a parliamentary debate just as news broke of the incident in Tehran and he made no comment on it.

(Additional reporting by Hossein Jaseb and Hashem Kalantari in Tehran, Parisa Hafezi in Istanbul, and William Maclean and Adrian Croft in London; Writing by Jon Hemming; Editing by Janet Lawrence)