Saudi Arabia cut diplomatic ties with Iran on Sunday and gave all Iranian diplomats 48 hours to leave the kingdom, as escalating tensions over the execution of an outspoken Shiite cleric in Saudi Arabiamarked a new low in relations between the two Middle Eastern powers.

The surprise move, announced in a televised news conference by Adel al-Jubeir, the Saudi foreign minister, followed harsh criticism by Iranian leaders of the Saudi execution of Sheikh Nimr al-Nimr and the storming of the Saudi Embassy in Tehran by protesters in response.

Mr. Jubeir said that the kingdom would not allow Iran to undermine the kingdom’s security.

The supreme leader of Iran, Ayatollah Ali Khamenei, warned Saturday thatSaudi Arabia would face divine vengeance for the execution of Sheikh Nimr, a day after Iranian protesters ransacked the Saudi Embassy in Tehran. Saudi Arabia, which put the cleric to death in a mass execution of 47 men accused of terrorism-related offenses, fired back, saying Iran had “revealed its true face represented in support for terrorism.”