KABUL, Afghanistan — An American Special Forces soldier was killed in eastern Afghanistan during a joint operation with Afghan forces against affiliates of the Islamic State, officials said on Sunday.

“The soldier was mortally wounded late Saturday during an operation in Nangarhar Province,” Capt. Bill Salvin, a spokesman for the American forces in Afghanistan, said.

The death was the first American casualty in Afghanistan from hostile fire since the beginning of the year, according to a tally kept by the website iCasualties. Last year, 13 American soldiers died in the country, 10 because of enemy fire. In total, 2,217 American soldiers have died in Afghanistan since the invasion in 2001 and another 20,000 have been wounded, according to the Pentagon.

About 8,400 American soldiers remain in Afghanistan, carrying out two missions — one under NATO’s mission to train and assist Afghan forces, and a second counterterrorism mission focused on Al Qaeda and affiliates of the Islamic State. The United States commander in Afghanistan, Gen. John W. Nicholson, has expressed the need for thousands more American soldiers ahead of what is expected to be a tough fighting season.