A U.S. service member died during a commando raid in Iraq on Thursday morning, the first American killed in action by enemy fire while fighting Islamic State militants.

A team of "dozens" of U.S. Special Forces troops joined Kurdish Ppeshmerga fighters in a predawn raid of a detention facility run by the Islamic State group near the northern Iraqi town of Hawija, about 90 miles south of the Kurdish city of Irbil, a defense official said.

The U.S. service member suffered a gunshot wound and was evacuated by helicopter to a U.S. base in Irbil, where he died, the defense official said.

For months the Pentagon has maintained that the roughly 3,500 U.S. troops deployed to Iraq do not engage in direct combat and their mission is limited to training, advising and assisting Iraqi forces from secure military installations.

It's unclear why U.S. forces moved forward into a direct combat setting in this particular raid.

Pentagon spokesman Peter Cook said the operation was launched after receiving information that dozens of hostages faced imminent mass execution.

"It was authorized consistent with our counter-ISIL effort to train, advise and assist Iraqi forces," Cook said, referring to the Islamic State group by an alternative acronym.

The U.S. provided helicopter lift and accompanied Iraqi Ppeshmerga forces to the compound, where they rescued some 70 hostages, including more than 20 members of the Iraqi security forces," Cook said.

The defense official said the U.S. also provided key intelligence and air support for the mission.

U.S. and Kurdish forces killed several Islamic State militants and detained five others, Cook said in a statement Thursday.

In addition, to the American casualty, four Ppeshmerga soldiers were wounded, Cook said.

The Islamic State group has been in control of the area around Hawija for several months, but the Iraqi military and the U.S.-led coalition have been pressing a counteroffensive against the militants.

The Hawija district, about 30 miles south of Kirkuk, has a population of about 400,000 people.

The service member killed Thursday was the first American to die in a combat operation by enemy fire while fighting Islamic State militants. At least seven others have been killed in other situations since Operation Inherent Resolve began last year.

Capt. William Dubois, 30, was killed in December when his F-16 crashed shortly after takeoff from a base in the Middle East. Dubois, of New Castle, Colorado, was assigned to the 77th Fighter Squadron at Shaw Air Force Base, South Carolina.

Tech. Sgt. Anthony Salazar, 40, died of a noncombat-related injury April 13. Salazar was a native of Hermosa Beach, California. He was assigned to the 577th Expeditionary Prime Base Engineer Emergency Force Squadron, part of the 1st Expeditionary Civil Engineer Group.

Marine Cpl. Jordan Spears, 21, was the first service member who died supporting Operation Inherent Resolve. On Oct. 1, 2014, he was aboard an MV-22 that had just taken off from the assault ship Makin Island when the Osprey plummeted toward the water. Ordered to ditch, Spears jumped out of the Osprey, but he was weighed down by his body armor and sank after his life vest failed to deploy. His body was never found.

Marine Lance Cpl. Sean Neal, 19, died Oct. 23, 2014, in Baghdad in a noncombat-related incident. Neal, of Riverside, California, was on his first deployment. He joined the Marine Corps in July 2013 and was assigned to the 2nd Battalion, 7th Marines at Twentynine Palms, California.

Navy Petty Officer 3rd Class Ryan Burris, 24, died May 21 in Zayed Military City, Abu Dhabi, United Arab Emirates, in a non-combat-related incident. Burris, of Lisle, Illinois, was temporarily assigned to the Crisis Response Element of Joint Special Operations Task Force — Arabian Peninsula, Special Operations Command Central, U.S. Central Command.

Navy Petty Officer 3rd Class Devon Doyle, 21, died May 16 when he fell from a balcony in Manama, Bahrain, while he was on liberty. Doyle, of Alamosa, Colorado, was assigned to the Mayport, Florida-based destroyer Farragut, which was part of the Theodore Roosevelt Carrier Strike Group.

Army Pfc. Monterrious Daniel, 19, died June 12 at Camp Buehring, Kuwait, in a non-combat-related incident. The Defense Department did not announce the cause of his death. Daniel, of Griffin, Georgia, was assigned to the 68th Combat Sustainment Support Battalion, 43rd Sustainment Brigade, 4th Infantry Division at Fort Carson, Colorado. He joined the Army in April 2014 and deployed to Kuwait in February.

Two other members of the coalition have been killed while supporting Operation Inherent Resolve:

Lt. Moaz Kasasbeh, a Jordanian F-16 pilot, was captured by the Islamic State group Dec. 24 after being shot down. He was murdered in January, when the Islamic State group burned him alive.

Sgt. Andrew Joseph Doiron, from the Canadian Special Operations Regiment, was accidentally killed by Kurdish forces March 6.