* Riyadh cuts ties with Tehran over storming of its embassy
* Cleric Nimr was vocal critic of ruling Al Saud family
* Iran's Supreme Leader warns of "divine vengeance"
* Long history of rivalry between the two regional powers
Saudi Arabia cut ties with Iran on Sunday, responding to the storming of its embassy in Tehran in an escalating row between the rival Middle East powers over Riyadh's execution of a Shi'ite Muslim cleric.
Foreign Minister Adel al-Jubeir told a news conference in Riyadh that the envoy of Shi'ite Iran had been asked to quit Saudi Arabia within 48 hours. The kingdom, he said, would not allow the Islamic republic to undermine its security.
Iranian protesters stormed the Saudi embassy in Tehran early on Sunday and Shi'ite Iran's top leader, Ayatollah Ali Khamenei, predicted "divine vengeance" for the execution of Sheikh Nimr al-Nimr, an outspoken opponent of the ruling Al Saudi family.
Jubeir said the attack in Tehran was in line with what he said were earlier Iranian assaults on foreign embassies there and with Iranian policies of destabilising the region by creating "terrorist cells" in Saudi Arabia.
"The kingdom, in light of these realities, announces the cutting of diplomatic relations with Iran and requests the departure of delegates of diplomatic missions of the embassy and consulate and offices related to it within 48 hours. The ambassador has been summoned to notify them," he said.
Speaking on Iranian state television, Deputy Foreign Minister Hossein Amir-Abdollahian said in Tehran's first response that by cutting diplomatic ties, Riyadh could not cover up "its major mistake of executing Sheikh Nimr".
The United States, Saudi Arabia's biggest backer in the West, responded by encouraging diplomatic engagement and calling for leaders in the region to take "affirmative steps" to reduce tensions.
"We believe that diplomatic engagement and direct conversations remain essential in working through differences and we will continue to urge leaders across the region to take affirmative steps to calm tensions," an official of President Barack Obama's administration said.
Tensions between revolutionary, mainly Shi'ite Iran and Saudi Arabia's conservative Sunni monarchy have run high for years as they backed opposing forces in wars and political conflicts across the Middle East, usually along sectarian lines.
However, Saturday's execution of a cleric whose death Iran had warned would "cost Saudi Arabia dearly", and the storming of the kingdom's Tehran embassy, raised the pitch of the rivalry.
Strong rhetoric from Tehran was matched by Iran's Shi'ite allies across the region, with Sayyed Hassan Nasrallah, the head of Lebanese militia Hezbollah, describing the execution as "a message of blood". Moqtada al-Sadr, an Iraqi Shi'ite cleric, called for angry protests.
Demonstrators protesting against the execution of the cleric, Sheikh Nimr al-Nimr, broke into the embassy building, smashed furniture and started fires before being ejected by police.
Iran's President Hassan Rouhani condemned the execution as "inhuman", but also urged the prosecution of "extremist individuals" for attacking the embassy and the Saudi consulate in the northeastern city of Mashhad, state media reported.
Tehran's police chief said an unspecified number of "unruly elements" were arrested for attacking the embassy with petrol bombs and rocks. A prosecutor said 40 people were held.
"The unjustly spilled blood of this oppressed martyr will no doubt soon show its effect and divine vengeance will befall Saudi politicians," Iran's Supreme Leader Ayatollah Ali Khamenei was quoted as saying by Iran's state television.
Nimr, the most vocal critic of the dynasty among the Shi'ite minority, had come to be seen as a leader of the sect's younger activists, who had tired of the failure of older, more measured, leaders to achieve equality with Sunnis.
His execution, along with three other Shi'ites and 43 members of Al Qaeda, sparked angry protests in the Qatif region in eastern Saudi Arabia, where demonstrators denounced the ruling Al Saud dynasty, and in the nearby Gulf kingdom of Bahrain.
Relatives of Nimr, reached by telephone, said authorities had informed them that the body had been buried "in a cemetery of Muslims" and would not be handed over to the family.
Although most of the 47 men killed in the kingdom's biggest mass execution for decades were Sunnis convicted of al Qaeda attacks in Saudi Arabia a decade ago, it was Nimr and three other Shi'ites, all accused of involvement in shooting police, who attracted most attention in the region and beyond.
Khamenei's website carried a picture of a Saudi executioner next to notorious Islamic State executioner 'Jihadi John', with the caption "Any differences?". The Revolutionary Guards said "harsh revenge" would topple "this pro-terrorist, anti-Islamic regime".
Saudi Arabia on Saturday summoned the Iranian ambassador to protest what it described as hostile remarks emerging from Tehran. On Sunday, Riyadh's Gulf allies the United Arab Emirates, Kuwait and Bahrain also summoned Tehran's envoys to their countries to lodge complaints.
IRAQ ALSO FURIOUS
In Iraq, whose Shi'ite-led government is close to Iran, religious and political figures demanded that ties with Riyadh be severed, calling into question Saudi attempts to forge a regional alliance against Islamic State, which controls swaths of Iraq and Syria.
Iraq's top Shi'ite cleric Grand Ayatollah Ali al-Sistani described the executions as an "unjust aggression". The opinion of Sistani, based in the Shi'ite holy city of Najaf south of Baghdad, carries weight with millions of Shi'ites in Iraq and across the region, including in Saudi Arabia.
Despite the focus on Nimr, the executions seemed mostly aimed at discouraging jihadism in Saudi Arabia, where dozens have died in the past year in attacks by Sunni militants.
But Saudi Arabia's Western allies, many of whom supply it with arms, are growing concerned about its new assertiveness.
The U.S. State Department said Nimr's execution "risks exacerbating sectarian tensions at a time when they urgently need to be reduced", a sentiment echoed by EU foreign policy chief Federica Mogherini. The State Department also urged Saudi Arabia to respect and protect human rights.
France said on Sunday it deeply deplored the mass execution and said it reiterated its opposition to the death penalty in all circumstances.
In Istanbul, hundreds of protesters, some carrying pictures of Nimr and chanting "Saudi Arabia will pay the price", gathered outside its consulate on Sunday as riot police stood guard.
The four Shi'ites had been convicted of involvement in shootings and petrol bomb attacks that killed several police during anti-government protests from 2011-13. More than 20 Shi'ites were shot dead by the authorities in those protests.
Family members of the executed Shi'ites have denied they were involved in attacks and said they were only peaceful protesters against sectarian discrimination.
Human rights groups say the kingdom's judicial process is unfair, pointing to accusations that confessions have been secured under torture and that defendants in court have been denied access to lawyers. Riyadh denies torture and says its judiciary is independent.