The United Nations has said it is investigating "disturbing reports of serious harm to civilians" in an Afghan airstrike on a religious school, which according to security sources left dozens of children dead or wounded.

"Human Rights team on ground establishing facts. All parties reminded of obligations to protect civilians from impact of armed conflict," the United Nations Assistance Mission in Afghanistan said in a brief statement.

Hundreds of people were attending a graduation ceremony at the madrassa in a Taliban-controlled district in northeastern Afghanistan yesterday when Afghan Air Force helicopters struck.

At least 59 people, including Taliban commanders meeting at the compound in the Dashte Archi district in Kunduz province, were killed in the attack.

Most of the civilian victims were children, according to Afghan security sources.

Witnesses said more than 50 people were wounded in the attack. They were driven more than 50km to hospital for treatment.

So far, the defence ministry has denied civilians were among the casualties.

"Twenty Taliban, including the commander of their Red Unit in the district, and also a key member of the Quetta Shura were killed," said a defence ministry spokesman.

The Red Unit is the insurgent group's elite unit and the Quetta Shura is its leadership council.

The Taliban confirmed the attack on the madrassa but denied militants had been meeting at the religious school.

US and Afghan forces are increasing ground and air offensives against Taliban and Islamic State insurgents as they try to get the upper hand in the 16-year war.