Fighters from the self-styled Islamic State (IS) group have attacked government buildings in the Iraqi city of Kirkuk, killing at least six police officers and 16 civilians.
Twelve IS jihadists were also killed in the dawn attack.
Hours later, witnesses said gunfire was still being heard and militants were walking openly through the streets.
Separately, Iraqi pro-government forces are continuing an offensive to re-take the IS-held city of Mosul to the north.
A news agency affiliated to IS claimed its fighters had broken into Kirkuk’s town hall and seized a central hotel, but officials denied this.
The governor of Kirkuk said the attack was carried out by IS sleeper cells.
Local media said a state of emergency had been declared and Friday sermons cancelled as mosques remained closed.
IS fighters also stormed a power plant to the north of Kirkuk. A mayor in Kirkuk said 16 people were killed. Iranian employees are believed to be among the dead.
The power plant, which is still under construction, is being built by an Iranian company.
In the city itself, militants concentrated on targets linked to the Iraqi government.
A district police chief, Brig Gen Sarhad Qadir, told the BBC that militants and a number of suicide bombers had attacked three police buildings and the headquarters of a political party in Kirkuk.
“All of the militants who attacked the police emergency building and the old building of the Kirkuk police directorate have been killed, but a number of other militants are still in Dumez district,” he said.
But Kirkuk’s governor, Najm al-Din Karim, told the Kurdish news agency, Rudaw, that Kurdish Peshmerga fighters and counter-terrorism forces were completely in control of the situation.
He told the agency that the attackers, from IS sleeper cells, had been “foiled” and reasoned for the motives behind the attack: “Because of the ongoing Mosul offensive, they may want to create a situation where forces would be withdrawn from there and the focus shifted to Kirkuk. Also because they are being defeated in Mosul, they want to boost their morale with these kinds of actions.”
In the latest on the Mosul offensive, Iraqi government forces said on Friday that they had regained control of two villages – al-Awaizat and Nanaha – south of Mosul, evacuating 65 displaced families and killing 15 IS militants.
A local TV channel broadcast footage of black smoke rising over the city, with automatic gunfire audible. Witnesses told the AFP news agency they had seen dozens of gunmen carrying grenades and rifles walking through the streets.
A security source meanwhile told the BBC there were ongoing clashes between IS militants and Peshmerga in the south and south-west of Kirkuk.
Kirkuk, a multi-ethnic city that is located about 180 miles (290km) north of the capital Baghdad and 105 miles (170km) south-east of Mosul. It is claimed both by Iraq’s central government and by the country’s Kurds.
It is thought the IS supporters behind this attack may have originally entered Kirkuk posing as displaced villagers fleeing nearby fighting.
Join GhanaStar.com to receive daily email alerts of breaking news in Ghana. GhanaStar.com is your source for all Ghana News. Get the latest Ghana news, breaking news, sports, politics, entertainment and more about Ghana, Africa and beyond.