A US Navy Seal killed during a firefight in Iraq was part of a team that moved in to rescue military advisers from an Islamic State (IS) attack, the Pentagon confirmed.
The attack triggered a massive coalition air response that destroyed equipment, buildings and killed up to 60 militants.
Navy Petty Officer 1st Class Charles Keating was shot and killed when he and special operations forces went to the rescue of US advisers that got caught in a gun battle involving more than 100 IS fighters, Col Steve Warren said.
The small team of advisers went to Teleskof, about 14 miles north of Mosul, to meet with Kurdish peshmerga forces.
Col Warren said IS fighters launched a large, complex attack on the peshmerga there with armoured Humvees and bulldozers, and broke through the front lines.
It was one of the largest attacks that the IS group has launched in recent months, and it came in the wake of several recent defeats of the militants in the region.
Col Warren said the US advisers were less than two miles behind the front lines, and called for help just before 8am local time. The quick reaction force went in to get the American forces out.
Col Warren said Petty Officer Keating was hit at about 9.30am and was evacuated for medical treatment, but "his wound was not survivable".
He said Petty Officer Keating was taken to a medical facility in Irbil and that both of the Black Hawk medical evacuation helicopters were hit by small arms fire.
According to Col Warren, as the US advisers were being rescued from the fight, a barrage of coalition aircraft - including F-15 and F-16 fighter jets, B-52 bombers, A-10 close air support aircraft and drones - responded and launched air strikes on more than 30 locations, destroying truck bombs, vehicles and bulldozers and killing close to 60 enemy fighters.
He said the peshmerga have regained control of the town.
Col Warren declined to release details about the quick reaction force, other than to note that often such teams are set up and put on standby when US forces go out on missions in dangerous areas.
The team of commandos is usually stationed relatively close by so that it can respond quickly if needed.
Petty Officer Keating, 31, is the third US service member to be killed in combat in Iraq since US forces returned there in mid-2014 to help the Iraqi government regain the wide swaths of territory captured by IS.
His death came as Defence Secretary Ash Carter was meeting in Germany with defence leaders from 11 coalition countries, and agreed to accelerate the fight against the IS group.
In a joint statement issued after the meeting in Stuttgart, the group reaffirmed its support "to further accelerate and reinforce the success of our partners on the ground and for the deployment of additional enabling capabilities in the near term".
The added: "We called on all of Iraq's political leaders to commit themselves to the legal and peaceful reconciliation of political differences in order to confront the nation's challenges and to remain united against the common enemy."
Mr Carter said he regretted Petty Officer Keating's death but stressed that combat risks in Iraq are unavoidable.
He said: "Our overall approach is to enable local forces to do the fighting... but that doesn't mean we aren't going to do any fighting at all.
"We are putting these people at risk every day... and, tragically, losses will occur."
He added that as the war intensifies, "these risks will continue".
Petty Officer Keating's mother said her son wanted to serve his country and that he died doing what he loved.
Krista Joseph, of Jacksonville, Florida, said: "He was our golden boy with a million-dollar smile and a heart of gold."
Petty Officer Keating was a grandson of Arizona financier Charles H Keating Jnr and grew up in Phoenix, where he was a star distance runner in high school.