Tehran (AFP) - Iran has sacked a senior security official over his failure to stop the ransacking of Saudi Arabia's embassy, which led the Sunni-ruled kingdom to sever diplomatic relations.

Safar Ali Baratlou's replacement as security deputy to Tehran's governor general was already under review, but the interior ministry said "a blind eye could not be turned" to what happened at the embassy.

The mission and the Saudi consulate in Mashhad, Iran's second city, were attacked and torched on January 2 in anger over Riyadh's execution of Nimr al-Nimr, a prominent cleric from the kingdom's Shiite minority.

"After initial investigations, failures... were confirmed" in connection with the "assault on the Saudi embassy", the ministry said late Sunday, cited by the official IRNA news agency.

"Because of the importance of the matter, the interior ministry cannot overlook the smallest failures and factors that led to this incident," the statement added of the attack and Baratlou's dismissal.

Riyadh cut diplomatic ties with Tehran after the incidents, deepening the crisis over the execution.

Other Arab countries followed suit and severed or reduced relations with Iran, a predominantly Shiite state.

Iranian President Hassan Rouhani strongly condemned the attacks as "totally unjustifiable", urging judiciary chief Ayatollah Sadegh Larijani to deal with wrongdoers immediately.

About 50 people have been arrested over the attacks.

"Once and for all such assaults on the country's security, an insult to the establishment's authority and position, should be prevented by punishing perpetrators and those who ordered this blatant crime," Rouhani said in a letter to Larijani on Wednesday.

For his part, Foreign Minister Mohammad Javad Zarif, in an opinion piece in The New York Times, stressed Iran's determination to deal with the attackers.

"We took immediate measures to help restore order... We also took disciplinary action against those who failed to protect the embassy," wrote Zarif.

Baratlou's sacking was followed by the replacement of General Hassan Arabsorkhi, head of police special forces in Tehran.

Officials have not said if that was linked to the embassy attack.