BAGHDAD — With American bombs raining down from the sky, Shiite militia fighters aligned with Iran battled Sunni extremists over the weekend, punching through their defenses to break the weekslong siege of Amerli, a cluster of farming villages whose Shiite residents faced possible slaughter.

The fight in northern Iraq appeared to be the first time American warplanes and militias backed by Iran had worked with a common purpose on a battlefield against militants from the Islamic State in Iraq and Syria, even though the Obama administration said there was no direct coordination with the militias.

Should such military actions continue, they could signal a dramatic shift for the United States and Iran, which have long vied for control in Iraq. They could also align the interests of the Americans with their longtime sworn enemies in the Shiite militias, whose fighters killed many United States soldiers during the long occupation of Iraq.

The latest expansion of American military operations reflects how seriously Iraq has deteriorated since the withdrawal of American forces in 2011. But any decision to support the Shiite militias, who have proven more adept than the American-trained Iraqi Army, would come with its own set of challenges.