A Somali woman who said she was raped by state security forces, and a journalist who interviewed her, were each sentenced on Tuesday to a year in jail in a trial that human rights advocates called "a terrible miscarriage of justice".

The 27-year-old woman was accused of insulting a government body and making false claims. The court in the capital, Mogadishu, said it based its decision on medical evidence that she was not raped, but the judge deferred her sentence until she has weaned her child.

The freelance reporter Abdiaziz Abdinur Ibrahim, who interviewed the woman in early January but never filed a story, was also charged with insulting state institutions. The two defendants are expected to appeal.

"The court's decision to convict an alleged rape victim and the journalist who interviewed her is a terrible miscarriage of justice, and sends a chilling signal to victims of sexual assault in Somalia," said Daniel Bekele, Africa director at Human Rights Watch.

"The case was built on groundless charges and serious due-process violations, and should have been thrown out. The government should swiftly move to exonerate and release the defendants."

The US state department has said the case is "a litmus test" for the future of Somalia. Human Rights Watch said last week that the case was politically motivated and designed to silence those who report on the pervasive problem of sexual violence by state security forces.

The international outcry surrounding the case is an embarrassment for the Somali president, Hassan Sheikh Mohamud, whose election last year was described by the international community as the start of a new era for Somalia after decades of instability and conflict.

The trial started as the Mohamud toured Europe to garner international support to rebuild Somalia.

He was in Britain on Monday where he met the international development secretary, Justine Greening.

The foreign secretary, William Hague, said he had discussed the case with Mohamud. He tweeted: "Raised current rape case of concern in Somalia with the President, including the importance of victims feeling able to speak out."

The judge in the case, Ahmed Aden Farah, said on Tuesday that the woman was sentenced for offending state institutions by claiming she was raped, the AFP news agency reported.

"She will spend one year in prison after finishing the breastfeeding of her baby," the agency quoted him as saying. The woman's husband and two others who were also detained over the case have been released.

The woman was arrested on 10 January, two days after she was interviewed by Abdinur Ibrahim and told him she had been raped by government forces last year. Police interrogated her over two days without legal counsel and released after saying she had retracted her story.

There have been some signs of official discomfort over the progress of the case. On Sunday, Somalia's prime minister, Abdi Farah Shirdon Saaid, said authorities would do more to protect rape victims, and he promised to reform the armed forces and judiciary once the trial had concluded.

"We recognise the concerns of our international partners and we are only too aware of the enormous challenges our nation faces," he said in a statement.

The international community, especially Britain and the US, have enthusiastically backed Somalia's new government, which emerged last September after a UN-backed peace process to replace a corrupt and inefficient transitional authority. International donors have pledged millions of dollars to rebuild the country, including money destined for the security forces.

Somalia has been enjoying a period of relative stability since African Union forces pushed the Islamic militants of al-Shabaab out of most of their urban strongholds, including the capital. The rebels still control some rural areas and carry out sporadic bomb attacks in Mogadishu