TEHRAN, Iran - Iran's top leader on Sunday warned Saudi Arabia of "divine revenge" over the execution of an opposition Shiite cleric while Riyadh accused Tehran of supporting terrorism, escalating a war of words hours after protesters stormed the Saudi Embassy in Tehran.

Saudi Arabia announced the execution of Sheikh Nimr al-Nimr on Saturday along with 46 others, including three other Shiite dissidents and a number of al Qaeda militants. It was largest mass execution carried out by the kingdom in three and a half decades.

Al-Nimr was a central figure in protests by Saudi Arabia's Shiite minority until his arrest in 2012, and his execution drew condemnation from Shiites across the region.

Iran's Supreme Leader Ayatollah Ali Khamenei condemned the execution Sunday in a statement on his website, saying al-Nimr "neither invited people to take up arms nor hatched covert plots. The only thing he did was public criticism." Iran's powerful Revolutionary Guard said Saudi Arabia's "medieval act of savagery" in executing the cleric would lead to the "downfall" of the country's monarchy.

Get Breaking News Delivered to Your Inbox

Saudi Arabia's Foreign Ministry said that by condemning the execution, Iran had "revealed its true face represented in support for terrorism."

The statement, carried by the official Saudi Press Agency, accused Tehran of "blind sectarianism" and said that "by its defense of terrorist acts" Iran is a "partner in their crimes in the entire region."

Al-Nimr was convicted of terrorism charges but denied ever advocating violence.

Sunni Saudi Arabia and Shiite Iran are locked in a bitter rivalry, and support opposite sides in the wars in Syria and Yemen. Iran accuses Saudi Arabia of supporting "terrorism" in part because it backs Syrian rebel groups, while Riyadh points to Iran's support for the Lebanese Hezbollah and other Shiite militant groups in the region.

The Iranian Foreign Ministry has summoned the Saudi envoy in Tehran to protest, while the Saudi Foreign Ministry later said it had summoned Iran's envoy to the kingdom to protest Iran's criticism of the execution, saying it represented "blatant interference" in its internal affairs.

In Tehran, the crowd gathered outside the Saudi Embassy early Sunday and chanted anti-Saudi slogans. Some protesters threw stones and Molotov cocktails at the embassy, setting off a fire in part of the building, said the country's top police official, Gen. Hossein Sajedinia, according to the semiofficial Tasnim news agency. He later said police had removed the protesters from the building and arrested some of them, adding that the situation had been "defused."

Hours later, Tehran prosecutor Abbas Jafari Dowlatabadi said 40 people had been arrested on suspicion of taking part in the embassy attack and investigators were pursuing other suspects, according to the semi-official ISNA news agency.

Iranian President Hassan Rouhani, while condemning Saudi Arabia's execution of al-Nimr, also branded those who attacked the Saudi Embassy as "extremists."

"It is unjustifiable," he said in a statement.

Protesters holding a banner saying "Death is normal to us and our dignity from God is martyrdom" take part in a protest against the execution of Saudi Shi'ite cleric Nimr al-Nimr by Saudi authorities, in the village of Sanabis, west of Manama, Bahrain January 2, 2016. REUTERS

The cleric's execution could also complicate Saudi Arabia's relationship with the Shiite-led government in Iraq. The Saudi Embassy in Baghdad is preparing to formally reopen for the first time in nearly 25 years. Already on Saturday there were public calls for Prime Minister Haider al-Abadi to shut the embassy down again.

Al-Abadi tweeted Saturday night that he was "shocked and saddened" by al-Nimr's execution, adding that "peaceful opposition is a fundamental right. Repression does not last."

On Sunday, Iraq's top Shiite cleric, Grand Ayatollah Ali al-Sistani, called al-Nimr a martyr and said his blood and that of other Shiite protesters "was unjustly and aggressively shed."

Hundreds of al-Nimr's supporters also protested in his hometown of al-Qatif in eastern Saudi Arabia, in neighboring Bahrain where police fired tear gas and bird shot, and as far away as northern India.

The family of al-Nimr plans to hold three days of mourning, though they say they weren't able to claim his body. The sheikh's brother, Mohammed al-Nimr, told The Associated Press that Saudi officials told his family that the cleric was already buried in an undisclosed cemetery.

Al-Nimr said they would hold three days of mourning beginning Sunday night at the Imam Hussein Mosque in al-Awamiya, a village in eastern Saudi Arabia, where the Shiite minority is concentrated. He said bakeries, pharmacies, shops and gas stations in the area will close out of respect.

The last time Saudi Arabia carried out a mass execution on this scale was in 1980, when the kingdom executed 63 people convicted over the 1979 seizure of the Grand Mosque in Mecca, Islam's holiest city. Extremists held the mosque, home to the cube-shaped Kaaba toward which Muslims around the world pray, for two weeks as they demanded the royal family abdicate the throne.

Also Sunday, the BBC reported that one of the 47 executed in Saudi Arabia, Adel al-Dhubaiti, was convicted over a 2004 attack on its journalists in Riyadh. That attack by a gang outside of the home of a suspected al-Qaida militant killed 36-year-old Irish cameraman Simon Cumbers. British reporter Frank Gardner, now the BBC's security correspondent, was seriously wounded in the attack and paralyzed, but survived.