A 10-year-old Afghan boy who helped lead a militia fighting terrorists alongside his uncle, then left to attend fourth grade, was shot in the head and killed by Taliban insurgents while walking to school, officials revealed Wednesday.

Police had called the boy a hero. Photographs on social media showed Wasil Ahmad holding an automatic weapon and wearing a uniform and helmet.

Afghan insurgents killed the boy near his home in Tirin Kot, the capital of the southern Uruzgan province, deputy police chief Rahimullah Khan said.

Ahmad's uncle was formerly a Taliban commander who changed allegiance to the government and was appointed local police commander in Khas Uruzgan district, Khan said.

"He fought like a miracle," the boy's uncle, Mullah Abdul Samad, said, according to Sky News. “He was successfully leading my men on my behalf for 44 days until I recovered."

The use of child soldiers is illegal in Afghanistan, but the charity Child Soldiers International said both government forces and insurgents have been recruiting minors for years.

The organization's policy and advocacy director Charu Lata Hogg told The Associated Press that the Afghan government, despite pledging to stop the recruitment and use of children by the Afghan security forces, was making "slow and tardy progress."

"There is a lack of political will to address this issue, and while it's within the framework of overall human rights violations, there is a specific commitment by the government to clean it up but sufficient measures are not being taken," she said.

In a June 2015 report presented to the U.N. Security Council's working group on children and armed conflict, the London-based charity said children were recruited by the Afghan National Police and the Afghan Local Police. It said the recruitment was mainly driven by poverty, but also filial duty, patriotism and honor.

The ALP, set up with U.S. and British funding to provide security at a district level, has been widely criticized for a range of abuses, including extortion, as in many places it operates much like an independent militia. The government has been urged to disband the force but relies on it to supplement the over-stretched army and police.

The report said that in May of last year the charity found that half of national police checkpoints in Tirin Kot "were staffed with visibly younger officers," who all acknowledged they were under 18 years old.

"They had been performing all responsibilities of a police officer, which included securing checkpoints and engaging in combat for the last few years," the report said.

The Afghanistan Independent Human Rights Commission laid blame for the boy's death with his family, the government and the Taliban, a militant group that has been fighting a 15-year insurgency.

Spokesman Rafiullah Baidar said that local police had hailed the boy as a hero after he battled a Taliban siege following the death of his father in fighting.

"Possibly he took up arms to take revenge for his father's death, but it was illegal for the police to declare him a hero and reveal his identity, especially to the insurgents," Baidar said.

"One side made him famous and the other side killed him -- both sides ignored the law and acted illegally," he said.

Afghanistan ratified the U.N. Convention on the Rights of the Child in 1994, committing the country to end the recruitment and use of child soldiers.

The Child Soldiers International report says that in the troubled Kunar, Logar and Zabul provinces "10 percent of law enforcement officials are suspected to be underage." Although statistics are not available, recruitment is believed to be highest where the insurgency is strongest, notably the southern provinces of Kandahar and Helmand, and provinces bordering Pakistan.

Children are also used by the Taliban in active combat, as spies and as suicide bombers, the report said. It cited a number of attacks, including one last year on the French Institute in Kabul during a packed performance that killed at least two people and wounded another 20.

Children recruited into the armed forces or insurgent groups are vulnerable to sexual abuse, Child Soldiers International said.

Despite a decree from President Ashraf Ghani last February criminalizing underage recruitment into the armed forces, the government has "failed to implement proactive mechanisms to identify, verify and release children" who had been recruited, the report said.

Click for more from Sky News.

The Associated Press contributed to this report.