BAGHDAD — An American soldier was killed in action in Iraq for the first time since the renewed military intervention here last year, during a Kurdish and United States commando raid to free prisoners being held by Islamic State militants on Thursday, the Pentagon said.

The raid, near the northern town of Hawija, freed about 70 prisoners but not the group the soldiers had expected to find, American and Iraqi officials said. American officials said that five Islamic State fighters had been detained and that important intelligence about the terrorist group had been recovered.

The raid was the first time American soldiers had been confirmed to be directly accompanying local forces in Iraq onto the battlefield against the Islamic State since President Obama sent troops back to the country last year. Until now, the American contingent, which numbers around 3,500, had been limited to training and advising the Iraqi and Kurdish forces on military bases and training areas. But senior American military officials have long signaled that they might ask the White House for permission to send small teams into the field with Iraqi forces for some important operations, such as the battle for Mosul.

The Pentagon press secretary, Peter Cook, said the United States was trying to help a loyal ally — the Kurdish Regional Government — and was also rushing to save lives.