U.S. forces engaged in the deadly raid to free ISIS hostages in northern Iraq after they saw the prisoners' "graves had been prepared," Defense Secretary Ash Carter said Friday.

He reiterated that U.S. service members were in "advise and assist" roles, saying that the plan was not for American forces to enter the firefight. However, he later added, "This is combat, things are complicated."

Secretary Carter said the freed hostages explained what they had experienced after the rescue, adding that "we could see" the graves next to the compound.

One American was killed in the raid, the first U.S. service member to die in the ground fight against ISIS in Iraq. The Pentagon identified him as 39-year-old Master Sgt. Joshua L. Wheeler of Roland, Oklahoma, and said his body would return to the U.S. Saturday.

Pentagon officials say he died from enemy fire during the operation to free as many as 70 Arab hostages. They say he was assigned to Special Operations Command at Fort Bragg in North Carolina.

More On This...

Dozens of U.S. special operations troops and Iraqi forces raided the compound Thursday, killing and capturing a number of militants, and recovering what the Pentagon called a trove of valuable intelligence about the terrorist organization.

Pentagon press secretary Peter Cook said the target of the raid was a prison near the town of Hawija and that the raid was undertaken at the request of the Kurdish Regional Government, the semi-autonomous body that governs the Kurdish region of northern Iraq. He said U.S. special operations forces supported what he called an Iraqi peshmerga rescue operation.

The peshmerga are the Kurdish region's organized militia. The U.S. has worked closely with them in training and advising roles, but this was the first known instance of U.S. ground forces operating alongside Iraqi forces in combat since launching Operation Inherent Resolve last year.

"This operation was deliberately planned and launched after receiving information that the hostages faced imminent mass execution," Cook said, adding later that it appeared the hostages faced death "perhaps within hours" and that freed hostages told authorities some had been killed at the prison recently, prior to the rescue.

Cook said Secretary Carter approved the U.S. participation in the mission. Cook called it "consistent with our counter-ISIL effort to train, advise and assist Iraqi forces."

U.S. combat troops have rarely, if ever, participated directly in combat against IS fighters on the ground since the U.S. mission began in 2014. The U.S. has mostly limited its role to training and advising Iraqi and Kurdish forces, airdropping humanitarian relief supplies and providing daily airstrikes in ISIS-held areas of Iraq and Syria.

Cook said it was a "unique" circumstance for the American military in Iraq, although he would not say that it was the only time U.S. forces have engaged in a form of ground combat in Iraq as part of Operation Inherent Resolve. He said it was in keeping with the parameters of the U.S. military's role in Iraq.

"They are allowed to defend themselves, and also defend partner forces, and to protect against the loss of innocent life," Cook said. "And that's what played out in this particular operation."

In a separate statement, the Kurdish government said the operation lasted about two hours and was led by its counterterrorism forces, with support from coalition troops. It made no mention of intelligence indicating the captives were in imminent danger of being killed, as asserted by the Pentagon.

The Kurdish statement said more than 20 ISIS fighters were killed in the operation about four miles north of Hawija. It said 69 hostages were freed, none of whom were Kurds, and it thanked the Americans for their bravery.

The Islamic State group released a communique late Thursday dismissing what it called "a failed operation by the crusader coalition" since peshmerga fighters were not among the rescued hostages. The statement could not immediately be verified, but it was distributed on Twitter accounts with links to the group.

Cook said four peshmerga soldiers were wounded.

The Associated Press contributed to this report.