Updated

KABUL (AP) — NATO and Afghan forces came under heavy fire while searching a compound in eastern Afghanistan, sparking a gunbattle that killed two U.S. soldiers and five insurgents, NATO said Friday.

Among the dead was a Taliban commander with ties to the Haqqani group, a Pakistan-based Afghan Taliban faction with close ties to al-Qaida, NATO said.

The casualties came during a joint military operation in the Puli Alam district, where coalition forces had gotten word of "insurgent activity" in the compound.

"As the combined force approached the compound they began receiving hostile fire from different points, including heavy machine gun fire," NATO said in a statement.

A search of the compound later turned up automatic rifles, material for making roadside bombs and blasting caps.