While many Iraqi Shiites took to the streets in outrage over Saudi Arabia's execution of a prominent Shiite cleric, the country's prime minister has had to walk a more cautious line, trying to contain Iraq's own explosive sectarian tensions.

The execution of Sheikh Nimr al-Nimr has inflamed the sectarian divide across the region. Shiite-led Iran has been the most vocal in its condemnation, and protesters stormed Saudi diplomatic missions in Iran over the weekend. That prompted Sunni-led Saudi Arabia to cut diplomatic relations with Iran, and the kingdom's allies have lined up behind it, either cutting or reducing their ties with Tehran.

The government of Iraq, however, is straining to keep the peace amid the regional tumult. Iran is a key ally of the Shiite-led government in Baghdad, has helped it in the fight against the Islamic State group, and supports powerful Shiite militias in the country.

At the same time, as the fight against IS extremists enters its second year, Iraq is grappling with the worst political and security crises since the withdrawal of U.S. troops in 2011. Only last week, Saudi Arabia sent an ambassador to Baghdad for the first time in 25 years to try to improve its relationship with Iraq.

In a sign of the government's caution, Prime Minister Haider al-Abadi issued a statement expressing regret over al-Nimr's execution and warning that such actions would "bring more destruction and devastation."

His office followed that Tuesday with a call for unity among Iraqis. Regional tensions should be faced "wisely, responsibly and rationally in order to preserve the security and stability of Iraq," according to a statement from al-Abadi's office.

A day earlier, thousands of Shiites gathered a few hundred meters (yards) from his office and called for the government to sever diplomatic ties with Riyadh. The protesters, supporters of prominent Shiite cleric Muqtada al-Sadr, chanted that al-Nimr's blood had not been spilled in vain and that the Mahdi Army, Sadr's disbanded Shiite militia, would avenge his death if needed.

That points to the government's bigger fear: That the regional dispute over al-Nimr's execution will turn into new violence between Iraq's Shiites and Sunnis.

Sectarian violence has quickly spiraled out of control in Iraq in the recent past, and a renewed form could disrupt Baghdad's campaign against the Islamic State group, the Sunni extremists who control large parts of the north and west of the country.

Iranian-backed Shiite militias, whose might rivals that of the military and security forces, have been a major factor in the fight, and the government has already had to cede them considerable authority. At the same time, al-Abadi has sought to encourage reconciliation with the Sunni minority, among whom hatred of the militias is strong, and include Sunnis in the fight against IS.

"This is the last thing (al-Abadi) needs after the high point in Ramadi," said Kirk Sowell, publisher of the Inside Iraqi Politics newsletter, referring to the recent government victory pushing IS fighters out of the western Iraqi city.

While al-Nimr's execution is unlikely to change Iraq-Saudi policy in any meaningful way, it does have the potential to set off violence in Iraq, Sowell said.

Two Sunni mosques were attacked in the southern town of Hilla in apparent retaliation for the execution, but al-Abadi was quick to blame IS and order a buildup of security in the province.

A group of powerful Shiite militias with strong ties to Iran, including Asaib al-Haq and the Badr Brigade, demanded the government cut diplomatic ties with the kingdom, expel the ambassador and execute all Saudis held in Iraqi prisons on charges of terrorism.

Acceding to their demands risks disillusioning Sunnis, who already accuse the government of being too beholden to the militias and who often see neighboring Sunni powerhouses like Jordan, Qatar and Saudi Arabia as allies.

"What you have right now is a split," said Sajad Jiyad, a fellow at the Iraqi Institute for Economic Reform in Baghdad, describing the opposing interests al-Abadi is struggling to satisfy. "The prime minister will find himself having to do something or face risking his popular appeal."

Al-Abadi may lack the ability to get ahead of a potential crisis, Jiyad said.

"It's unclear how much control the government has in Iraq," he said.