Somalia's internationally-backed government on Tuesday sprung to the defence of the judiciary following the sentencing of a woman who said she was raped along with the two journalists who broadcast her story.

Spokesman Ridwaan Haji said war-torn Somalia's courts were in their "infancy" and needed to time to improve.

"We have an independent judiciary in Somalia and the government cannot and must not be involved in the administration of justice," he said in a statement.

"Our new, independent judiciary, like many institutions in the new Somalia, is in its infancy. It will take time to develop and evolve into an institution that delivers justice effectively and inspires public confidence."

Haji also said while the government supported "a free press and freedom of speech", journalists were also obliged to "take their role in society seriously and demonstrate social responsibility".

The alleged rape victim, who is 19 and is herself also a journalist, last month told the independent Radio Shabelle she was attacked at gunpoint by two fellow journalists.

On Monday a court handed her a suspended six-month jail sentence for defamation and lying, during which time she will be confined to her home.

Two journalists who reported her story -- and not the alleged attackers -- were also sentenced to one year and six months respectively. They can pay a fine in order to win early release.

Neither of the men accused of the rape were arrested.

Rape, and reporting on sexual assault, is one of the most sensitive topics in Somalia, and it is the second time this year a Somali court has jailed a woman for speaking out about rape and journalists for interviewing her.

In August, a Somali woman who said she was gang-raped by African Union soldiers was also held by police for questioning.

The Somali government has repeatedly said that rape and sexual violence against women "are completely unacceptable in Somali culture", but has previously declined to comment on specific cases.