KABUL, Afghanistan — An explosion Sunday killed seven Afghan villagers as they tried to pull bodies of dead insurgents from the rubble of a village mosque after a night raid by NATO and Afghan troops, officials said. Four insurgents and an Afghan soldier were also reported killed in the operation.

Night raids have long been a contentious issue between Afghanistan’s president, who says he does not want international troops in Afghan villages, and the NATO alliance, which says they are key to capturing Taliban commanders.

Even though Sunday’s deaths came hours after the troops left, locals were quick to protest against the U.S. troops that operate in the area.

“Death to America!” one man shouted as he shook his fist, shown in an Associated Press video. The villagers displayed the bodies of the dead wrapped in blankets and sheets.

The predawn operation in Sayd Abad district was aimed at capturing a Taliban fighter who had holed up in a village, said Wardak province spokesman Shahidullah Shahid. The international and Afghan forces captured the militant but came under attack from insurgents, sparking a two-hour gunfight during which at least one large blast was heard, he said. Four insurgents were dead by the time fighting ended around 4:30 a.m.

Then about 6 a.m. local time, residents came out to find the local mosque partly destroyed and started digging through the rubble to uncover bodies. Shahid says something exploded as they dug, killing seven civilians. He says the insurgents were wearing suicide bomb vests, but it was not immediately clear if that caused the explosion.

A spokesman for international forces in Afghanistan confirmed that four insurgents were killed but did not have any immediate reports of civilian deaths.

“I am aware of reports that indicate there may have been civilians killed, and ISAF and Afghan officials are assessing the situation to determine the facts,” said Jamie Graybeal, a spokesman for the international military coalition in Afghanistan.

He said that there was no airstrike as part of the operation, but the NATO and Afghan troops did discover a large cache of weapons, which they destroyed on the site, causing a large explosion.

The NATO force said in a statement that an Afghan soldier was also killed in the operation.