Iran is intervening in Iraq to quell destabilizing internal unrest stirred up by Iranian-backed militias. The actions come as Tehran seeks to preserve its deep influence in the country while also navigating tense negotiations over its nuclear ambitions with the United States.

A particularly high-level intervention came last month, hours after an attack on the Iraqi prime minister’s residence that some officials in Baghdad blamed on Iran-backed groups.

One of Tehran’s most senior military commanders, Brigadier General Esmail Ghaani, rushed to Baghdad, according to militia officials, Iraqi politicians close to the militias, Western diplomats and an Iraqi security source familiar with the talks. Ghaani had a message for pro-Iranian militias refusing to acknowledge initial results of Oct. 10 parliamentary elections in which Shi’ite Muslim cleric Moqtada al-Sadr, a populist candidate opposed to Iranian influence, was the top vote-winner. Ghaani’s message: Accept the result.