Human Rights Watch (HRW) said on Wednesday al Shabaab Islamists had forcibly recruited thousands of children - some as young as nine - and hundreds have been detained by Somali authorities.
The detentions violate a 2014 agreement by the government to treat child detainees separately and work with the United Nations to rehabilitate them, the HRW report said.
Government ministers for justice and human rights did not respond to requests for comment. The chairman of Somalia's military courts, Liban Ali Yarow, told Reuters he did not speak to the media.
Clan elder Ugas Mohamed Wali, said his two nephews aged 12 and 13 were arrested on their way to school last year, along with 17 other teenagers. Both boys were jailed for eight years, he said.
"There are many problems in Somalia. Children are seized and arrested if accidentally they are passing near a blast scene," he said, showing pictures of the two boys on his mobile phone.
"The 17 teenagers were released when they were brought to Mogadishu because they were from rich families. We had no money and so the two kids were taken into the underground cell where they were tortured."
HRW cited U.N. figures saying Somali security forces arrested 386 children in 2016 during operations targeting al-Shabaab. Many were released after their parents paid bribes or clan elders intervened, but those whose families lacked money or influence were kept.
Authorities have handed over 250 children to the United Nations for rehabilitation since 2015, the report said, but that was often after months of pressure.
"In a justice system that remains heavily reliant on forced confessions, children are not spared," the report said, adding that children were "threatened and on occasion beaten, at times in ways that amount to torture".
Fahmo Mantan Warsame told Reuters her 17-year-old son was arrested three years ago and sentenced to 10 years in jail for being a member of al Shabaab and that she had paid a total of $3,700 to various officials to try to free him.
"They ask you money at every door you go to. The one who writes a letter asks for money. The one who claims he will release a child asks for money. Nothing else. And when they have bled you dry, and after they take all money, they switch off their phones," she said.