An American soldier was killed in northern Iraq overnight during a special operation to rescue hostages held by Islamic State (IS) militants, according to US and Iraqi Kurdistan officials.

In a statement released on Thursday, the Pentagon said US and Iraqi Peshmerga forces had received information suggesting that the hostages, held by IS in a prison, faced imminent mass execution.

During the two-hour operation that began at 2am (00:00 GMT), at least 69 hostages, including 20 members of the Iraqi forces, were freed near the town of Hawija. Early reports suggested Kurds were among the hostages who were rescued, but a KRG statement said none of those freed were Kurds. The identity of the remaining hostages was not clear late Thursday.

A US soldier, whom the Pentagon said was shot by IS and died after receiving medical care, is the first American killed in action in Iraq since the US withdrew from the country in 2011. Four Peshmerga soldiers were wounded.

The raid marks the first firefight between US forces and IS in Iraq, a US official told CNN.

At least five members of IS were captured during the attack and at least 20 others were killed, a KRG statement said. The Pentagon also said that "important intelligence" about the militant group was seized.

A US official who spoke with AFP underlined that the operation was Iraqi-led with the US military playing an "advise and assist" role.

Pentagon press secretary Peter Cook pushed back against the suggestion that this signalled an expansion of the US role in Iraq.

"This is a unique situation," he said, adding that the mission was given the green light by Defense Secretary Ashton Carter, and that the White House was notified.

"We were asked for assistance" by the Kurdish government, Cook said, stressing that "the United States are not in an active combat mission in Iraq."

Residents told AFP that several Chinook helicopters were involved in the raid and that several IS-run checkpoints in the area were targeted by air strikes.

Cook said US helicopters and special operations forces accompanied Kurdish Peshmerga forces to the prison compound. The American who later died was wounded "acting in support of Iraqi Peshmerga forces after they came under fire from ISIL," he said.

The mission was "authorised consistent with our counter-ISIL effort to train, advise, and assist Iraqi forces."

'Tough fight'

General Lloyd Austin, the commander of all US forces in the Middle East, described the rescue operation as "complex and highly successful."

"We commend and congratulate the brave individuals who participated in this successful operation that saved many lives, and we deeply mourn the loss of one of our own who died while supporting his Iraqi comrades engaged in a tough fight," he said.

Those freed included prisoners who were about to be executed as spies, and residents of Hawijah, a coalition official in Iraq said.

"They'd executed four the previous day. We had seen mass graves had been dug on that compound and the information we now hear... is that they'd been told they would be executed after morning prayers this morning," the official told AFP.

The overnight attack is one of a handful of offensives attempted in the area, an IS stronghold, over the past year.

At the end of September, 3,500 Iraqi Kurdish forces, backed by US-led coalition warplanes, led a ground offensive in which at least 16 Kurdish Peshmerga fighters and dozens of IS fighters were killed.

The US has deployed 3,500 troops in Iraq for the operation targeting the Islamic State group.

These troops are meant to train, advise and assist Iraqi forces which have been weakened and suffered from poor morale ever since multiple divisions collapsed in the face of an offensive by IS last year.