Jihadists staged a brazen raid on the Iraqi city of Kirkuk Friday, in what appeared to be an attempt to divert attention from the huge offensive against their Mosul bastion.
Residents awoke to the sound of shooting and praise for the "Islamic State" blaring through mosque loudspeakers.
Some attackers, whom one senior Kirkuk official numbered around 100, carried grenades and wore explosives vests or belts in the assault claimed by the Islamic State group.
An AFP reporter attended the interrogation of one suspected jihadist who said after being captured by Kurdish forces that the attack was designed to ease the pressure on the Mosul front to the northeast.
"Today's attack was one of caliph Baghdadi's plans to demonstrate that the Islamic State is remaining and expanding and reduce the pressure on the Mosul front," he said.
The young man in a grey tracksuit had his hands cuffed and gave his name as Hani Aydan Mustafa, but his role in IS was unclear.
Two years ago in Mosul, Abu Bakr al-Baghdadi declared a "caliphate" straddling Iraq and Syria.
One of its main slogans was to remain and expand but it has been shrinking steadily since last year and losing Mosul could mean the end of its days as a land-holding force in Iraq.
The attack on Kirkuk, a strategic city some 240 kilometres (150 miles) north of Baghdad, demonstrated the group's continued ability to time its attacks and grab headlines.
"Around morning prayers, I saw several Dawaesh (IS fighters) enter Al-Mohammadi mosque," Haidar Abdelhussein, a teacher in the Tesaeen neighbourhood, told AFP.
- Sniper risk -
"They used the loudspeakers to shout 'Allahu Akbar' (God is greatest) and 'Dawla al-Islam baqiya' (Islamic State remains)," he said.
At least five suicide bombers targeted government buildings, including Kirkuk's main police headquarters. At least six policemen and 12 jihadists were killed in clashes.
A senior police officer said the main obstacle to flushing out holdout attackers was the risk from snipers.
Iraqi Prime Minister Haider al-Abadi's office announced that reinforcements would be dispatched to Kirkuk to help track down remaining attackers and end the crisis.
A journalist for a local Turkmen television station was killed by an IS sniper, and health officials also said 51 wounded residents were evacuated to nearby hospitals.
A curfew was in place and sporadic gunfire could still be heard as night fell on what was now a war zone, with armoured vehicles taking up position and security forces manning rooftops or crouching behind walls.
IS is unlikely to hold positions in Kirkuk for long, and its attack had no immediate impact on the offensive against Mosul, the biggest Iraqi military operation in years.
The governor of Kirkuk, Najmeddin Karim, told AFP he suspected the involvement of IS sleeper cells.
Signup to our newsletter and follow us on Facebook and Twitter!
Kurdish peshmerga fighters have played a major role in the Mosul advance, and both they and federal security forces have made gains on several fronts.
Political and military leaders have praised what they say is speedier than expected progress, with IS offering deadly but so far ineffective resistance as forces backed by air strikes steamroll towards the edge of Iraq's second city.
- Suicide bombers -
The jihadists defenders of Mosul are vastly outnumbered and the final outcome is hardly in doubt.
But they have been launching waves of suicide bombers to make the anti-IS drive as slow and painful as possible.
Also on Friday morning, gunmen wearing suicide vests stormed a power plant being built by an Iranian company near Dibis, a town southeast of the Mosul offensive's main area of operations, and just 40 kilometres (25 miles) from Kirkuk.
"Three suicide bombers attacked the power plant at around 6:00 am (0300 GMT), killing 12 Iraqi administrators and engineers and four Iranian technicians," Dibis mayor Abdullah Nureddin al-Salehi told AFP.
A police lieutenant colonel confirmed the casualty toll from the attack, which was also claimed by IS.
IS controlled more than a third of Iraq two years ago, but its self-proclaimed "caliphate" has been shrinking steadily.
A 60-nation US-led coalition and neighbouring Iran have helped Iraqi forces regain one city after another, and Mosul is now the group's last major stronghold in the country.
US Defence Secretary Ashton Carter said Friday he was confident that Turkey would take part in the battle to retake Mosul, following tensions between Ankara and Baghdad over the presence of Turkish troops in northern Iraq.
"I think there is agreement there in principle," he said in Abu Dhabi after a visit to Turkey.
- 'Ultimate sacrifice' -
The jihadist group claimed responsibility for at least five suicide car bomb attacks om Kurdish forces attacking their positions northeast of Mosul.
"Up to 10,000 peshmerga are involved in this operation from three fronts, making it one of the largest ground-led assaults in the war against ISIL," the peshmerga command said in a statement.
Iraqi forces have not provided figures for their losses, but the statement said "a number of peshmerga have paid the ultimate sacrifice".
The coalition announced that a US service member accompanying elite Iraqi forces northeast of Mosul was killed on Thursday.
According to the United Nations, 5,640 people were displaced in the first three days of the operation that Prime Minister Haider al-Abadi declared on October 17.
It said up to 1.2 million people may still be inside Mosul, trapped by the estimated 3,000 to 4,500 IS fighters digging in for a major urban assault by the advancing Iraqi forces.
The aid community fears an exodus of massive proportions that could peak as winter sets in without sufficient shelter capacity for refugees.