Some scenes show bearded, armed fighters from around the Arab world renouncing their home countries and shredding their passports. Other scenes show them preaching at mosques and soliciting pledges of allegiance to Mr. Baghdadi. Still other scenes emphasize attacks. Its fighters carry out drive-by shootings against men they accuse of being in the Iraqi army, in some cases chasing them through fields before grabbing and executing them.

The group has calibrated different strategies for Syria and Iraq. In Syria, it has mainly focused on seizing territory that has already fallen out of government hands, but had been poorly controlled by other rebel groups. In Iraq, though, it has exploited widespread disenchantment among the country’s Sunnis with the government of Prime Minister Nuri Kamal al-Maliki, to align with other Sunni militant groups, such as one organization that is led by former officers of Saddam Hussein’s Baath Party.

Though many of these groups, including the Baathists and other tribal militias, seemed to have joined with ISIS because of a common enemy, its organization and resources could lure them to a more durable alliance that could make it even more difficult for Mr. Maliki’s government to reassert control.

“What is very dangerous is that all these forces now have the same goal,” said Hassan Abu Hanieh, a Jordanian expert on Islamist groups. “ISIS has been able to take advantage of widespread anger and to base their identity on fighting Shiites.”