U.S. officials are praising the heroism of an American soldier who was killed while helping to save as many as 70 Islamic State hostages from near-certain death.

Defense Secretary Ash Carter said at a news conference Friday that the actions of Master Sergeant Joshua Wheeler, the first American to die fighting in Iraq in almost four years, might have been instrumental to the success of the mission, which came hours before the hostages were scheduled to die.

“We’ve now heard from rescued hostages [that] they expected to be executed that day after morning prayers," Carter said. "Their graves had already been prepared.”

Pentagon officials said about 60 U.S. and Iraqi Kurdish commandos were involved in the Thursday morning raid on an Islamic State prison compound, which Carter described as an "execution center." Officials said four hostages had been executed at the site just one day earlier.

Officials said the original plan was for Americans to stay back and advise while the Kurds entered the compound. But when the Kurds started taking heavy fire from IS defenders, the Americans jumped into the fight.

U.S. Master Sgt. Joshua Wheeler, killed in a raid against the Islamic State group in northern Iraq.

Wheeler "did what I’m very proud [that] Americans do in that situation," Carter said.

"He ran to the sounds of the guns and he stood up, and all the indications are it was his actions and that of one of his teammates that protected those involved in breaching the compound and made the mission successful,” he said.

Hawijah, in Kirkuk governate, Iraq

At least 22 members of the Iraqi security forces were among those saved in the commando raid in the northern Iraqi town of Hawijah. All the freed hostages were flown to Irbil, the capital of Iraq's Kurdish regional government, which approved the raid.

Colonel Steve Warren, spokesman for the U.S.-led coalition in Iraq, told VOA that Wheeler was shot once and noted that Kurdish forces had taken casualties during the operation. A number of IS militants also were killed.

"This is the first raid of its type that's been this dramatic" because it was "behind enemy lines, saving hostages," Warren said.

President Barack Obama has been reluctant to commit U.S. ground troops to the fight Islamic State, and the U.S. role has for the most part been limited to airstrikes in support of Iraqi and Kurdish security forces. But the U.S. military is authorized to engage in combat to protect its own troops and partner forces.

Warren said that in this case, the Americans, being "men of action in the heat of the battle, made the decision to help. The commander on the ground made the call to go in and help clear out the enemies."

At the White House, deputy spokesman Eric Schultz said the raid did not violate the U.S. ban on combat operations in Iraq, but troops there are performing a potentially perilous job.

Obama "absolutely made clear these men and women were going to be serving in a dangerous place. They do, as you point out, put their lives on the line,” Schultz said.

While Americans have grown weary of the war in Iraq, which began with a U.S. invasion of Baghdad in 2003, analysts say American participation is critical if IS is to be defeated.

"The Kurdish Peshmerga need this kind of support because they do not have the air capability, they don’t have the reach that they need to defeat this adversary,” said Sarhang Hamasaeed, an expert with the U.S. Institute of Peace in Washington.