The commander of US and Nato troops in Afghanistan has apologised for civilian deaths in a coalition air strike this week, the first confirmation by Nato forces that civilians were killed in the operation.

Marine General John Allen flew to Logar province to express his regrets over the deaths in Wednesday's pre-dawn raid to capture a Taliban operative. Afghan officials have said the air strike called in by Nato troops killed 18 civilians.

"I know that no apology can bring back the lives of the children or the people who perished in this tragedy and this accident, but I want you to know that you have my apology and we will do the right thing by the families," Allen told the group of about two dozen Afghans gathered at a patrol base in the provincial capital, Pul-i-Alam.

Nato and Afghan officials have said the troops were on an operation to capture a Taliban leader who was holed up in a house in Sajawand village, in the Baraki Barak district. As they tried to breach the compound they came under fire and fought back, eventually calling in an air strike.

Villagers have said there was a wedding at the house the evening before and it was full of families visiting for the celebration. The morning after the bombing, they piled the bodies of the dead into vans and drove them to the provincial capital to protest.

Wali Wakil, an Afghan doctor who examined the bodies and interviewed two women injured in the strike, said a group of Taliban fighters decided to spend the night in the house because they thought the wedding would give them cover. When Nato and Afghan troops started advancing on the house in the middle of the night the troops called for any civilians to come out, but the insurgents did not allow them to leave, Wakil said.

"The Taliban stopped them from getting out of the house," he said. The 18 dead civilians were four women, two men, three teenage boys and nine children, and six Taliban fighters were killed, Wakil said, citing witnesses.

Allen said the troops did not know there were civilians inside the house when they called in the air strike. "They were taken under fire. A hand grenade was thrown. Three of our people were wounded. We called for the people who were shooting to come out and then the situation became more grave and innocent people were killed," he said. "Our weapons killed these people."

Allen met the Logar governor before taking his message to the assembled group at Pul-i-Alam. He said he kept seeing the faces of his own children as he thought about those who had been killed.

Night-time raids on militants taking cover in villages have been a repeated source of strain between the Afghan government and its international allies. Kabul says the raids put civilians in the crossfire; coalition forces say such operations are key to capturing and killing insurgent leaders.

A deal signed in April was supposed to resolve the issue by putting the Afghan government in charge of such operations, and the troops involved in Wednesday's raid included both Nato and Afghan military. But Hamid Karzai, the Afghan president, has put the blame for this week's deaths squarely on the international coalition, condemning their actions and calling for them to give a full account of how the civilian deaths occurred.