The American-backed coalition fighting the Islamic State in Iraq may have missed a chance to head off the attack by deferring a plan to take Hawija, a nearby Islamic State enclave. Hawija appears to have been the jumping-off point for some of the militants involved in the Kirkuk assault.

Officials said that there had been some intelligence reports earlier in the week that the government center might come under attack. But what ended up unfolding went far beyond what officials had expected, said the governor of Kirkuk Province, Najmiddin Karim, who trained as a neurosurgeon in the United States and has dual Iraqi and American citizenship.

About 100 Islamic State fighters had moved from towns like Hawija to an area near Daquq, where they were met early on Oct. 21 by seven trucks, apparently operated by drivers familiar with Kirkuk.

The fighters raced to several tactical spots in the city, including the tall buildings outside the emergency police headquarters, where they used snipers to bottle up the Kirkuk security forces, officials said. Still other militants took up positions in the Snowbar Hotel, which gave them a commanding view of the heavily secured government areas.

The governor called Lahur Talabani, the head of a Kurdish intelligence service, who with his brother Polad, the counterterrorism force officer, rushed to Kirkuk from Sulaimaniya.

But the Islamic State, also known as ISIS or ISIL, appeared to have anticipated that reinforcements would come from Sulaimaniya and had ambushes planned, firing rocket-propelled grenades and other weapons at the relief force and prompting it to take a more circuitous route, officials said. The Islamic State also began to run suicide car bomb attacks at front-line pesh merga forces, in an apparent effort to pin down those Kurdish troops so they could not be used for the defense of Kirkuk.

Not all of the Islamic State attackers were Sunni Arabs from Iraq. The attackers apparently included some Kurds and some foreign fighters from Yemen, Polad Talabani said.