"We extend our condolences to the families of the victims, and hope for the quick and full recovery of the wounded," deputy State Department spokesperson Marie Harf said in a statement on the attack, which took place near Egypt's desert frontier with restive Libya.
"A prosperous and dynamic Egypt requires an environment of security and stability, and the United States continues to support the Egyptian government's efforts to counter the threat of terrorism in Egypt as part of our commitment to the strategic partnership between our two countries."
The Egyptian military said militants firing machineguns and rocket-propelled grenades attacked a border checkpoint on Saturday, killing 21 soldiers in one of the biggest assaults on security forces in years.
The attack in a desert area 630km west of Cairo also left four soldiers wounded, the military said in a statement, blaming "terrorists".
Militants have stepped up attacks on the security forces since Islamist president Mohammed Morsi was toppled in July 2013 as the army struggles to quell an Islamist insurgency that has killed scores of soldiers and police, mainly in the Sinai Peninsula bordering Israel and the Palestinian Gaza Strip.
Harf's statement came just after US Secretary of State John Kerry arrived in Cairo on a delicate mission to broker a truce between Israel and the Palestinian Islamic movement Hamas in the Gaza Strip.