The NATO Resolute Support mission announced their deaths first, providing no details about what happened and saying that their names would be withheld for 24 hours until their families could be notified.
Later, a U.S. official said the two service members died in combat from small-arms fire without providing further information. The official spoke on condition of anonymity because the details had not yet been made public.
More than 2,400 U.S. military personnel have died in Afghanistan since the U.S.-led invasion in 2001 to topple the Taliban, whose government had harbored al-Qaida leader Osama bin Laden.
Now, the U.S. and Taliban are in negotiations on an end to nearly 18 years of fighting in America's longest war.
The U.S. formally ended its Afghan combat mission in 2014 but still provides extensive air and other support to local forces battling both the Taliban and an affiliate of the Islamic State group.
Associated Press writer Lolita C. Baldor in Washington contributed to this report.
Copyright 2019 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.