The effects of civil conflict on Somalia's children have been catastrophic, as many youngsters have been forced to fight

As the rattle of gunfire becomes louder, Mohamed Abdi sits in the corner of a Mogadishu restaurant wondering how much longer he can survive in one of the world's most dangerous capital cities. "Mogadishu is full of miseries. Sometimes you fall into traps and can be abducted by either government forces or insurgents, to fight for their cause," says the 15-year-old.

Thousands have been displaced because of fighting between government forces and al-Shabaab, a militant Islamist group linked to al-Qaida. Abdi is fortunate in that he recently found work as a waiter, but not so long ago he was involved in urban warfare.

As Somalia's civil conflict continues, the use of child soldiers is causing growing concern. In a report last month, Amnesty International detailed cases of children as young as nine being forced into combat. The report - In the line of fire: Somalia's children under attack – exposes the ongoing conflict's impact on children, arguing that both Somalia's transitional federal government and al-Shabaab are guilty of gross human rights violations.

"As a child in Somalia, you risk death all the time," says Michelle Kagari, Amnesty International's deputy director for Africa. "You can be killed, recruited and sent to the frontline, punished by al-Shabaab because you are caught listening to music or wearing the 'wrong' clothes, be forced to fend for yourself because you have lost your parents, or even die because you don't have access to adequate medical care."

Abdi's father died two years ago and it has since been a daily struggle for him to support his mother and two brothers, who live in a nearby refugee camp. He rarely leaves his workplace or ventures on to Mogadishu's streets for fear he might be abducted again. It was shortly after his father died in 2009 that Abdi was taken by al-Shabaab. He was initially accused of spying for the government and driven from Mogadishu to a training centre in Marka, about 60 miles from the capital. After receiving military instruction, he was moved back to Mogadishu.

"Children do tasks such as spying for the insurgents or the government, it depends which side they are working with, and they also assemble explosives. I fought in Industrial Street in Mogadishu. While on the frontline one night, I was on guard at our base in Shirkole. It was dark and two of my colleagues on duty fell asleep, so I managed to escape," says Abdi.

The teenager, whose family moved to Mogadishu four years ago from the Bay and Bakol regions of south Somalia, now washes plates and earns 60,000 Somali shillings, around $2 per day. He considers himself extremely lucky. Reports from lower Shabelle, Hiram, Middle Shabelle and the lower Jubba regions of Somalia - strongholds of al-Shabaab - indicate that child recruitment drastically increased after insurgents withdrew from the capital this month to allow aid agencies into the city.

"Children as young as nine were forcibly dragged from their homes for recruitment even though some of the children were not able to hold a gun," said Ali Mohamed, a father in the port town of Kismayo, whose missing son is believed to have been taken by al-Shabaab.

The effects of war have been catastrophic for children. According to Amnesty, many have been killed or injured in indiscriminate attacks carried out in densely populated areas. Access to education is also a problem. Many school buildings have been destroyed or damaged, while several schools in Mogadishu have closed down, with children and teachers alike fearful of being killed or injured en route to school.

Abdisalam Hared, a secondary school teacher in Mogadishu, is increasingly concerned about the influence radical Islamists have over children. He says some of his pupils told him he must dress like a Muslim and not wear jeans.

Mohamed Abdirahman, another high school teacher, says some pupils have links with the insurgents and have responded to calls from their amirs (group leaders) to join up with the fighters. "We let them go," says Abdirahman. "Some of them did not come back and were reportedly killed in the frontlines."

In militant-controlled areas of Mogadishu, al-Shabaab has imposed strict rules and ordered students to enlist in the fight against the government. The insurgents have banned non-Arabic signs on shops and ordered businesses in the Elasha settlement, on Mogadishu's outskirts, to remove English and Somali posters and replace them with billboards in Arabic.

Al-Shabaab is supposed to have left Mogadishu, but its fighters are still launching attacks from their city strongholds. Their strategy is now based on Afghan-style hit and run tactics designed for urban warfare. In northern parts of the city, remnants of al-Shabaab and their sympathisers launch regular attacks to show their presence. In the Huriwaa, Suukha Hoolaha and Huriwa districts, more than 10 people, including a woman and three young teenagers, have been beheaded over the past fortnight. All were accused of spying for the government, says Omer Ja'fan Abdulle, Huriwaa's district commissioner.

Elsewhere, life is dire for hundreds of orphaned children left destitute. According to Unicef, at least 2,000 children are trying to survive on Mogadishu's streets.

• Mohamad Shil is a correspondent with the International Network of Street Papers based in Mogadishu, Somalia