Iranian protesters chant slogans as they hold pictures of Shi'ite cleric Sheikh Nimr al-Nimr during a demonstration against the execution of Nimr in Saudi Arabia, outside the Saudi Arabian Embassy in Tehran January, 3, 2016. REUTERS/Raheb Homavandi/TIMA

DUBAI (Reuters) - Saudi Arabia used an attack on its embassy in Tehran as a pretext to fuel tensions, Iran's foreign ministry said on Monday after Riyadh severed diplomatic relations.

Iran was committed to protecting its foreign diplomatic missions, the ministry added.

Iranian protesters stormed the Saudi embassy in the early hours of Sunday after Saudi Arabia executed Shi'ite cleric Nimr al-Nimr, prompting Riyadh to withdraw its diplomatic staff and order Iranian diplomats to leave the kingdom.

The protesters lit fires and smashed furniture in the embassy before being cleared out by the police, who made 40 arrests. No Saudi diplomats were in the embassy. Iranian officials condemned the attack as well as Nimr's execution.

"Iran has acted in accordance with its (diplomatic) obligations to control the broad wave of popular emotion that arose," foreign ministry spokesman Hossein Jaberi Ansari said in televised remarks.

"Saudi Arabia benefits and thrives on prolonging tensions... (It) has used this incident as an excuse to fuel the tensions," he added.

Ansari said Iranian diplomats had not yet left Saudi Arabia. They were given 48 hours to leave late on Sunday night.

(Reporting by Sam Wilkin, Editing by William Maclean and John Stonestreet)