WASHINGTON — Gen. Qassim Suleimani, the shadowy commander of Iran’s paramilitary Quds Force, flew to Iraq this week with dozens of his officers to advise the country’s beleaguered leadership about how to blunt the advance of militant forces on Baghdad, American officials said Friday.

In meeting with General Suleimani, the Iraqis are hosting the mastermind of Iran’s strategy in Iraq when Iraqi Shiite militias trained by Iran fought American troops. The general is also the current architect of Iranian military support in Syria for President Bashar al-Assad.

The contact suggests that the Iraqis see the possibility of significant aid from Iran as a means of pressuring the United States to come to Iraq’s defense with aid of its own. And it highlights the complex web of alliances brought to the fore in the current crisis; both the United States and Iran, traditional antagonists, see it in their interest to come to the aid of an embattled partner to repel the advance of the Islamic State of Iraq and Syria, or ISIS.

“Clearly, any arrival and activation of Iranian military personnel on the ground in Iraq would be extremely significant, symbolically but also practically,” said Charles Lister, a visiting fellow at the Brookings Doha Center in Qatar. “The terrorism threat in Iraq is perceived strongly by both Iran and the U.S.”