KABUL, Afghanistan-- A 10-year-old Afghan boy who was declared a hero after fighting the Taliban has been shot dead by insurgents while on his way to school, officials said on Wednesday.

The deputy police chief of the province, Rahimullah Khan, said the boy, Wasil Ahmad, was killed in Tirin Kot, the capital of the southern Uruzgan province.

The boy had fought Taliban alongside his uncle on many occasions, Khan said. Photographs on social media showed ten-year-old Ahmad holding an automatic weapon and wearing uniform and a helmet.

Get Breaking News Delivered to Your Inbox

Khan said that unknown gunmen he referred to only as insurgents had killed the boy near his home.

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.

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

In a report presented to the U.N. Security Council's working group on children and armed conflict, the London-based group said children were recruited by the Afghan National Police and the Afghan Local Police for reasons that included a sense of fulfilling filial duty, patriotism and honor.

But the main reason was poverty, it said in the June 2015 report.

It said that in May last year it found that half of ANP check posts in Tirin Kot "were staffed with visibly younger officers" who all admitted they were under 18 years old.

"They had been performing all responsibilities of a police officer, which included securing check points 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, who have been waging war for 15 years.

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.