Tuesday's attack by hundreds of protesters followed Britain's decision to impose further sanctions on Iran over its nuclear programme.
The sanctions led to Iran's parliament reducing diplomatic ties with the UK.
"If any country makes it impossible for us to operate on their soil, they cannot expect to have a functioning embassy here," Mr Hague told MPs on Wednesday.
The foreign secretary said there had been "some degree of regime consent" in the attacks on the embassy and on another UK diplomatic compound in Tehran.
He also said all UK diplomatic staff in Tehran had been evacuated and the embassy closed.
Mr Hague said relations between the UK and Iran were now at their lowest level, but the UK was not severing relations with Tehran entirely.
Iran's foreign ministry called the British move "hasty", state TV reported, according to Reuters, and said Iran would take "further appropriate action".
Germany, France and the Netherlands announced on Wednesday that they were recalling their ambassadors to Tehran for consultation and Norway said it was temporarily closing its embassy there as a precaution.
Hundreds of protesters - whom Iran described as "students" - massed outside the embassy compound on Tuesday afternoon before scaling the walls and the gates, burning British flags and a car.
Another UK diplomatic compound in northern Tehran, known locally as Qolhak Garden, was also overrun and damaged.
Iran said it regretted the incident, which it described as "unacceptable behaviour by a small number of protesters".
Mr Hague said the majority of those taking part had been members of a regime-backed Basij militia group.
He said the private quarters of staff and the ambassador had been ransacked, the main embassy office set on fire and personal possessions belonging to UK diplomats stolen.
The US, EU and UN Security Council also condemned the attacks.
Last week, the US, Canada and the UK announced new sanctions against Iran, including measures to restrict the activities of the Iranian central bank.
The UK said then it was severing all financial ties with Iran.
The move followed a report by the UN's nuclear watchdog (IAEA) that said Iran had carried out tests "relevant to the development of a nuclear device".
Iran denies the accusations, saying its nuclear programme is solely for peaceful purposes.
On Sunday, Iran's parliament voted by a large majority to downgrade diplomatic relations with the UK in response to the recent action.