Afghan villagers gather near a house destroyed in an apparent NATO raid in Logar province, south of Kabul, Afghanistan on June, 6, 2012. Afghan officials and residents say a pre-dawn NATO airstrike aimed at militants killed civilians celebrating a wedding, including women and children. (Ihsanullah Majroh/AP)

The top American commander in Afghanistan apologized to Afghans on Friday for a coalition airstrike that killed women and children in Logar province earlier in the week.

Marine Gen. John Allen flew to Logar province, just south of Kabul, to meet with villagers and offer his condolences for the bombing Wednesday that Afghan officials said killed 18 civilians. The airstrike was called in by U.S. troops after they came under fire while pursuing a Taliban fighter in a village in the Baraki Barak district.

“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 Afghans, according to the Associated Press. NATO troops often make condolence payments to the families of victims in civilian casualty incidents.

Allen told an Associated Press reporter traveling with him that the troops did not know there were civilians inside the house at the time of the airstrike.

“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 told the AP.

“Our weapons killed these people,” Allen said.

The house that came under fire reportedly was full of civilians who had attended a wedding the night before. An Afghan doctor who examined the bodies told the AP that a group of Taliban fighters were taking cover among the members of the wedding party and that four women, two elderly men, three teenage boys and nine young children were among the dead.

U.S. military spokesman Lt. Col. Jimmie Cummings said that the insurgents who were firing refused a call by coalition and Afghan troops to stop and come outside and that “things escalated” until the troops called in air support. He said a NATO investigation was still underway.

After reports of civilian deaths emerged, President Hamid Karzai called a relative of the victims and cut short a trip to China, where he was participating in a summit in Shanghai.

“NATO operations that inflict human and material losses to civilians can in no way be justifiable, acceptable and tolerable,” Karzai said in a statement Thursday while Defense Secretary Leon E. Panetta was visiting Kabul. Karzai has voiced concerns about the war’s collateral damage for years.

Also Friday, Afghan officials said inmates in a prison in the northern city of Sar-e-Pul used a remote-controlled bomb to shatter the prison’s mud walls and escape into the night. The outbreak occurred about 8:30 p.m. Thursday and left at least three prisoners dead and more than 25 wounded, according to Gen. Mohammed Yaqub Zabuli, the provincial police chief.

Zabuli said that “one or two” prisoners escaped, but other provincial officials put the number as high as 25.

“The prison was too old, and the walls were too weak,” Zabuli said, adding that the remaining inmates had been transferred to another prison in northern Afghanistan.

Special correspondent Javed Hamdard contributed to this report.