TEHRAN, Iran — In scenes that evoked the seizing of the U.S. Embassy in 1979, hundreds of demonstrators stormed two British diplomatic compounds here Tuesday, hurling gasoline bombs, ransacking offices and tearing down the British flag.

The hours-long attacks, which followed a move by the Iranian parliament to expel Britain’s ambassador over new sanctions, marked a sharp escalation in the tension between Iran and the West over the Islamic Republic’s nuclear program.

Britain promised “serious consequences” and summoned Iran’s charges d’affaires in London to the Foreign Office. The incident also drew rebukes form the United States, France and the U.N. Security Council.

Iran’s Foreign Ministry voiced regret for “the unacceptable behaviors” by some demonstrators and said it had requested an immediate investigation.

The protest was organized to mark the anniversary of the death of nuclear scientist Majid Shahriari in an attack Iran blamed on British and Israeli intelligence agencies. A few hundred demonstrators gathered outside the British Embassy in downtown Tehran, chanting “Death to Britain” and demanding the immediate withdrawal of Ambassador Dominick Chilcott.

Some of the protesters climbed over the gates into the complex, where they tossed gasoline bombs and hoisted the Iranian flag in place of the British banner. They ripped down satellite dishes, tossed out papers and carried away a portrait of Queen Elizabeth II.

Other protesters forced their way into a British diplomatic compound in the north of the city, where they seized documents and staged a sit-in, according to a report by the semiofficial Fars news agency.

Iranian riot police seemed slow to react but regained control of both compounds within hours.

Fars said police had secured the release of six embassy employees taken hostage by protesters and arrested 12 people. But the official Islamic Republic News Agency said the demonstrators had been protecting the employees. The accounts could not be immediately reconciled.

British Foreign Secretary William Hague said it appeared all embassy staff were accounted for.