An Army helicopter crew member mans a gun on the rear gate as it departs Resolute Support headquarters in Kabul, Afghanistan on April 24. (Jonathan Ernst/Associated Press)

Two U.S. service members were killed during operations against the Islamic State in eastern Afghanistan, the U.S. military said Thursday, the latest sign of the security challenges the Trump administration faces in America’s longest and most costly war.

Military officials said the deaths occurred during a joint U.S.-Afghan raid on Wednesday evening in Nangahar province, where a small but virulent Islamic State cell poses a threat to Afghan and U.S. coalition forces.

A third service member was wounded in the same operation, the U.S. military command in Afghanistan said in a statement. 

The Pentagon on Friday identified Sgt. Joshua P. Rodgers, 22, and Sgt. Cameron H. Thomas, 23, as the Army Rangers killed. The soldiers were members of 3rd Battalion, 75th Ranger Regiment, an elite Army force that specializes in raid operations.

“The fight against ISIS-K is important for the world, but sadly, it is not without sacrifice,” said Gen. John Nicholson, the commander of U.S. troops in Afghanistan, referring to the Islamic State branch in Afghanistan, known as Islamic State-Khorasan Province.

The incident took place in Nangahar’s Achin district near a site where the U.S. military unleashed a massive 22,000-pound bomb this month, a sign of the scale of the ongoing conflict nearly 16 years after U.S. troops arrived in Afghanistan.

The recent fighting in Achin, including the first-ever use of the GBU-43 bomb and Wednesday’s incident, which killed two Americans, illustrates the danger posed by just one of multiple militant groups in a conflict that U.S. officials have described as a stalemate.

A Taliban resurgence across Afghanistan has meant that the government in Kabul controls only slightly more than half the country’s territory, according to a U.S. government watchdog, and that the United States has been forced to return forces to areas pacified at great cost under President Barack Obama’s 2009-2011 troop surge.

At the same time, local forces are struggling to contain an array of militant groups along the country’s border with Pakistan, including the Islamic State.

Faced with those challenges, the Trump administration is reevaluating its strategy for Afghanistan and considering sending additional U.S. troops to support local forces. Nicholson has called for thousands of extra service members to help train and support the Afghan military.

According to Navy Lt. Chris Donlon, a spokesman for U.S. forces in Afghanistan, Wednesday’s incident happened close to Achin and near where U.S. aircraft dropped the GBU-43 munition two weeks ago.

That bomb targeted a sprawling Islamic State tunnel complex, and although Afghan officials said between 36 and 100 Islamic State fighters were killed in the strike, the U.S. military has not announced what exactly the bomb accomplished.

An Afghan military official, who spoke on the condition of anonymity to discuss current operations, confirmed that there had been a joint U.S.-Afghan operation in a village near Achin district Wednesday but was not aware of any casualties. He said it had been a long day of fighting.

The Afghan branch of the Islamic State, mainly composed of militants pulled from other groups, has emerged as an increasing counterterrorism focus for the United States in Afghanistan. 

Although military officials say the group is far smaller than it was at its height in 2015, an estimated 600 to 800 militants, located mainly in remote mountainous areas, have proven to be a deadly adversary. Fighting has been fierce as U.S. and Afghan Special Operations forces, backed by hundreds of airstrikes, have sought to advance against militant strongholds in recent months. 

The deaths mark the third time this year that a member of the U.S. military has died in combat in Afghanistan. On April 8, Army Staff Sgt. Mark R. De Alencar, 37, of Edgewood, Md., was killed by small-arms fire, also in Nangahar. 

They come just days after Defense Secretary Jim Mattis visited Afghanistan to assess the security situation and advance deliberations about the Trump administration’s approach to a war that has largely been overshadowed by events in Iraq and Syria

Dan Lamothe in Washington and Sayed Salahuddin in Kabul contributed to this report.