QAYYARA, Iraq (Reuters) - Islamic State launched a major attack on the city of Kirkuk on Friday as Iraqi and Kurdish forces pursued operations to seize territory around Mosul in preparation for an offensive on the jihadists’ last major stronghold in Iraq.

Islamic State’s assault on Kirkuk, which lies in an oil- producing region, killed 18 members of the security forces and workers at a power station outside the city, including two Iranians, a hospital source said.

Crude oil production facilities were not targeted and the power supply continued uninterrupted in the city. Kirkuk is located east of Hawija, a pocket still under control of Islamic State that lies between Baghdad and Mosul.

With air and ground support from the U.S.-led coalition, Iraqi government forces captured eight villages south and southeast of Mosul. Kurdish forces attacking from the north and east also captured several villages, according to statements from their respective military commands overnight.

The offensive that started on Monday to capture Mosul is expected to become the biggest battle fought in Iraq since the U.S.-led invasion in 2003.

U.S. Defense Secretary Ash Carter said on Friday Turkey and Iraq had reached an agreement in principle that could allow a Turkish role in the Mosul campaign.

Speaking in Ankara after talks with Turkish President Tayyip Erdogan, Carter said the details still needed to be hammered out. NATO member Turkey sees Mosul as firmly within its sphere of influence, but Iraq views Turkish military moves on its territory with apprehension.

The United Nations says Mosul could require the biggest humanitarian relief operation in the world, with worst-case scenario forecasts of up to a million people being uprooted.

About 1.5 million residents are still believed to be inside Mosul. Islamic State has taken 550 families from villages around Mosul and is holding them close to IS locations in the city, probably as human shields, a spokeswoman for the U.N. human rights office said in Geneva.

The fighting has forced 5,640 people to flee their homes so far from the vicinity of the city, the International Organization for Migration said late on Thursday.

The Turkish Red Crescent said it was sending aid trucks to northern Iraq with food and humanitarian supplies for 10,000 people displaced by fighting around Mosul.

EXPLOSIVE DEVICE

A U.S. service member died on Thursday from wounds sustained in an improvised explosive device blast near the city.

Roughly 5,000 U.S. forces are in Iraq. More than 100 of them are embedded with Iraqi and Kurdish Peshmerga forces, advising commanders and helping them ensure coalition air power hits the right targets, officials say.

However, the Kurdish military command complained that air support wasn’t enough on Thursday.

Iraqi Prime Minister Haidar al-Abadi, addressing anti-Islamic State coalition allies meeting in Paris via video link, said the offensive was advancing more quickly than planned.

A senior Kurdish military official told Reuters the offensive by the Iraqi and Kurdish forces was moving steadily as they push into villages on the outskirts of Mosul.

But he expected the offensive to slow as they approach the city, where Islamic State has built trenches and dug tunnels.

“I believe it will be more clear within the coming weeks ... how quickly this war will end. If they (Islamic State) decide to defend the actual city then the process will slow down.”

Once inside Mosul, Iraqi special forces would have to move painstakingly from street to street to clear explosives and booby traps, the official said.

Islamic State denied that government forces had advanced. Under the headline “The crusade on Nineveh gets a lousy start,” the group’s weekly online magazine Al-Nabaa said it repelled assaults on all fronts, killing dozens in ambushes and suicide attacks and destroying dozens of vehicles including tanks.

Slideshow ( 23 images )

In online statements, Islamic State said it launched a series of counter-attacks and four suicide bombings to take back villages that fell on Thursday to the army and the Kurds and that it had blocked all their fresh offensives.

HOLED UP

In Kirkuk, Islamic State attacked several police buildings and a power station in the early hours of Friday and some of the attackers remained holed up in a mosque and an abandoned hotel.

The militants also cut the road between the city and the power station 30 km (20 miles) to the north.

Several dozen took part in the assault, according to security sources who couldn’t confirm a claim by Islamic State that it had taken a Kurdish police officer hostage.

Slideshow ( 23 images )

The assailants in Kirkuk came from outside the city, said the head of Iraq’s Special Forces, Lieutenant General Talib Shaghati, speaking on a frontline east of Mosul. Iran’s Foreign Ministry spokesman Bahram Ghasemi described the killing of the Iranian citizens in Kirkuk as “the last breath of terrorists in Iraq”.

At least eight militants were killed, either by blowing themselves up or in clashes with the security forces, the security sources said. Kurdish forces had dislodged the militants from all the police and public buildings they had seized before dawn, they said.

Kurdish NRT TV footage showed machine gun fire hitting a drab two-floor building that used to be a hotel, and cars burning in a nearby street.

Islamic State claimed the attacks in online statements, and authorities declared a curfew in the city where Kurdish forces were getting reinforcements.

Kurdish Peshmerga fighters took control of Kirkuk in 2014, after the Iraqi army withdrew from the region, fleeing an Islamic State advance through northern and western Iraq.

“LONG LIVE IRAQ”

On the frontline south of Mosul, thick black smoke lingered from oil wells that Islamic State torched to evade air surveillance, in the region of Qayyara.

The army and the U.S.-led coalition took back this region in August and are using its air base as a hub to support the offensive on Mosul.

“Long live Iraq, death to Daesh,” was painted on a wall near an army checkpoint there. Daesh is an Arabic acronym for Islamic State.

The army Humvees at the checkpoint carried Shi’ite flags, revealing that the soldiers of this unit belonged to Iraq’s majority religious community.

Flying Shi’ite flags in the predominantly Sunni Muslim region and the participation of the Popular Mobilization Force - a coalition of mostly Iranian-trained militias - in a support role to the army has raised concerns of sectarian violence and revenge killings during or after the battle.

Iraq’s top Shi’ite cleric, Grand Ayatollah Ali al-Sistani, on Friday renewed a call to spare civilians.

“All those who are participating in the battle have to respect the humanitarian principles and refrain from seeking vengeance,” said a sermon delivered in Sistani’s name in the holy Shi’ite city of Kerbala by one of his representatives.