China is a big consumer of crude oil from Iran, and has resisted proposed Western sanctions on Tehran’s nuclear ambitions that could stymie those energy ties. But the rowdy attacks on British diplomatic quarters in Tehran drew criticism from the Chinese Foreign Ministry.

“China has always maintained that the safety and dignity of diplomatic personnel and properties must be ensured and protected,” the ministry spokesman Hong Lei told a daily news briefing in Beijing, in answer to a question about the incident.

“The attacks in question were contrary to international law and rules, and they should be appropriately dealt with,” he said.

Iranian demonstrators stormed two British diplomatic compounds, smashing windows, torching a car and burning the British flag in protest against new sanctions imposed by London.

Britain said it was outraged. The UN Security Council, which includes China as a permanent member, condemned the attacks “in the strongest terms” and on Wednesday US Secretary of State Hillary Clinton described them as an “affront” to the international community.

China has kept close ties with Iran, but also backed past UN Security Council resolutions criticizing Iran’s position on nuclear issues and authorizing limited sanctions.

China has also, however, resisted Western proposals for sanctions that could seriously curtail its energy and economic ties with Iran. As one of the Security Council’s five permanent members, China holds the power to veto any resolutions.

Beijing has also denounced the United States and European Union for imposing their separate unilateral sanctions on Iran, and said they should not take steps reaching beyond the UN resolutions.